Skip to content

fix(plugin): keep utc mode when customParseFormat gets a format array - #3185

Open
official-burak wants to merge 1 commit into
iamkun:devfrom
official-burak:fix/custom-parse-format-utc-array
Open

fix(plugin): keep utc mode when customParseFormat gets a format array#3185
official-burak wants to merge 1 commit into
iamkun:devfrom
official-burak:fix/custom-parse-format-utc-array

Conversation

@official-burak

@official-burak official-burak commented Aug 25, 2026

Copy link
Copy Markdown

Fixes #3013

dayjs.utc(input, 'YYYY-MM-DD') parses in UTC, but dayjs.utc(input, ['YYYY-MM-DD', 'YYYY-M-D']) was going through dayjs(), which drops cfg.utc and builds a local Date. On a non-UTC host that silently shifts the instant (the issue's example: local midnight instead of 1995-05-01T00:00:00.000Z).

The array loop now constructs with the original utc flag so each candidate format uses the same path as a single format string.

Test

Added in test/plugin/utc.test.js. Failed on TZ=America/New_York before the change (1995-05-01T04:00:00Z), passed after. Existing customParseFormat array-format tests still pass.

Array formats were re-parsed through dayjs(), which drops cfg.utc and
reads the date in local time. Reconstruct with the original utc flag
so dayjs.utc(input, [...]) matches a single format string.
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.

Passing array value to format param to dayjs.utc() silently disables utc mode

1 participant