fix(timestamp): detect & convert microsecond/nanosecond epochs - #43
Merged
Conversation
Previously parseTimestamp treated any numeric string longer than 10 digits as milliseconds, so a 19-digit nanosecond value (e.g. 1784694237438743460) overflowed Date's range and failed with 'Could not parse that as a date or Unix timestamp.' Now the unit is inferred from digit length — ~10 = seconds, ~13 = ms, ~16 = µs, ~19 = ns — and normalized to milliseconds. The UI surfaces the detected unit so the interpretation is explicit. Seconds/millis cutoffs are unchanged, so existing behavior is preserved. Adds coverage for micro/nanosecond parsing and detectNumericUnit.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
goodwebtools | 48c5ef4 | Jul 27 2026, 08:21 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The timestamp converter errored on high-resolution epoch values like
1784694237438743460(19-digit nanoseconds) with "Could not parse that as a date or Unix timestamp." — any numeric string over 10 digits was assumed to be milliseconds, and 1.78×10¹⁸ ms is far outside JSDate's ±271k-year range.Fix
parseTimestampnow infers the unit from digit length (≈10 = seconds, ≈13 = ms, ≈16 = µs, ≈19 = ns) and normalizes to milliseconds. The seconds/millisecond cutoffs (≤10, ≤13) are unchanged, so all prior behavior is preserved. The UI shows a "Detected numeric input as Unix nanoseconds" note so the interpretation is explicit.1784694237438743460→ 2026-07-22T04:23:57Z.Tests
+4 cases (micro/nanosecond parsing, the reported value,
detectNumericUnit). Full suite 433 pass; lint clean.