fixed parsing date with time zone in dayjs.tz() #2774
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.
When we parse dates in dayjs.tz() with timezone we make time offset twice. So if the date string has timezone information better parse it in dayjs().
Before changes
dayjs("2024-09-30 12:43:00 +0300").format('LLLL z')
it returns the correct date:
Monday, September 30, 2024 12:43 PM GMT+3
dayjs.tz("2024-09-30 12:43:00 +0300").format('LLLL z')
it returns the incorrect date:
Monday, September 30, 2024 9:43 AM GMT+3
time was offset twice.
After changes
dayjs("2024-09-30 12:43:00 +0300").format('LLLL z')
it returns the correct date:
Monday, September 30, 2024 12:43 PM GMT+3
dayjs.tz("2024-09-30 12:43:00 +0300").format('LLLL z')
it returns the correct date:
Monday, September 30, 2024 12:43 PM GMT+3
time was offset once.