Skip to content

fix: parse zone-less fallback strings at the fixed offset in dateTimeUtc - #103

Merged
korvin89 merged 2 commits into
mainfrom
fix/utc-slash-date-102
Oct 30, 2026
Merged

korvin89 merged 2 commits into
mainfrom
fix/utc-slash-date-102

Conversation

@korvin89

Copy link
Copy Markdown
Collaborator

Closes #102

The native Date fallback from #91 parsed strings that no regex in parseDateString matches (e.g. "2024/01/01") in the system time zone, so dateTimeUtc() returned a value shifted by the local UTC offset (2023-12-31 21:00 instead of 2024-01-01 00:00 under Europe/Moscow).

With a fixed offset the fallback now uses dayjs.utc(input), as in 2.5.x, and shifts the result by the offset, same as the format branch. dayjs.utc reads zone-less YYYY/MM/DD-like strings as UTC and hands everything else (e.g. Date.toString() output from #91) to the native parser, so those still keep their instant. dateTime() without a fixed offset is unchanged.

The native Date fallback from #91 parsed strings like '2024/01/01' in the
system time zone, so dateTimeUtc returned a shifted instant outside UTC.
With a fixed offset, use dayjs.utc as in 2.5.x and shift by the offset.

Closes #102
@korvin89
korvin89 marked this pull request as ready for review October 30, 2026 12:19
@korvin89
korvin89 requested review from ValeraS and amje as code owners October 30, 2026 12:19
Comment thread src/dateTime/dateTime.ts Resolved
Co-authored-by: Valerii Sidorenko <balepas@nebius.com>
@korvin89
korvin89 merged commit bee794f into main Oct 30, 2026
@korvin89
korvin89 deleted the fix/utc-slash-date-102 branch October 30, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dateTimeUtc parses '2024/01/01' in local time since 2.6.1

2 participants