fix: handle Dayjs object input in dayjs.utc()#3036
Closed
Bahtya wants to merge 1 commit intoiamkun:devfrom
Closed
Conversation
When passing a Dayjs object to dayjs.utc(), the result was incorrect because the raw Dayjs object went through parseDate() which called new Date(date) producing wrong results. Add isDayjs check to convert to native Date first. Fixes #1241
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
When passing a Dayjs object to
dayjs.utc(), the result is incorrect — it returns today's date instead of the passed date.This happens because
dayjs.utc()passes the raw Dayjs object directly to the config, which goes throughparseDate()→new Date(date), producing incorrect results.Solution
Add an
isDayjscheck at the top ofdayjs.utc()to convert to a native Date first:This mirrors how the core
dayjs()function already handles Dayjs input.Fixes #1241