Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day.js doesn't parse ISO 8601 timezone offset +NN #1205

Closed
michaelmarziani opened this issue Nov 11, 2020 · 6 comments · Fixed by #1209
Closed

Day.js doesn't parse ISO 8601 timezone offset +NN #1205

michaelmarziani opened this issue Nov 11, 2020 · 6 comments · Fixed by #1209
Labels

Comments

@michaelmarziani
Copy link

Describe the bug
PostgreSQL is returning time with time zone fields in this ISO 8601 format: 2020-12-01T20:00:00+00. Note that it's using a 2-digit offset which is part of the ISO specification, along with the 4-digit colon-separated format (which Day.js parses fine).

Day.js doesn't parse this 2-digit format, it ignores the timezone if parsed normally, i.e. dayjs('2020-12-01T20:00:00+00'), and if given a custom format like dayjs('2020-12-01T20:00:00+00', 'YYYY-MM-DD[T]HH:mm:ssZZ'); it will return an Invalid date.

Sandbox w/ test and control strings: https://codesandbox.io/s/festive-glitter-mh7bx

Expected behavior
I expect this format to be parsed correctly like the 4-digit, colon separated ISO 8601 timezone offset format +NN:NN.

Information

  • Day.js Version: 1.9.6
  • OS: macOS
  • Browser: Chrome, Safari, Firefox
  • Time zone: GMT+1
@iamkun
Copy link
Owner

iamkun commented Nov 12, 2020

Will support in the next release.

iamkun pushed a commit that referenced this issue Dec 5, 2020
## [1.9.7](v1.9.6...v1.9.7) (2020-12-05)

### Bug Fixes

* add duration.format to format a Duration ([#1202](#1202)) ([9a859a1](9a859a1))
* Add function handling for relativeTime.future and relativeTime.past ([#1197](#1197)) ([ef1979c](ef1979c))
* avoid install installed plugin ([#1214](#1214)) ([a92eb6c](a92eb6c))
* avoid memory leak after installing a plugin too many times ([b8d2e32](b8d2e32))
* fix diff bug when UTC plugin enabled ([#1201](#1201)) ([9544ed2](9544ed2)), closes [#1200](#1200)
* fix startOf/endOf bug in timezone plugin ([#1229](#1229)) ([eb5fbc4](eb5fbc4))
* fix utc plugin diff edge case ([#1187](#1187)) ([971b3d4](971b3d4))
* update customParseFormat plugin to parse 2-digit offset ([#1209](#1209)) ([b56936a](b56936a)), closes [#1205](#1205)
* Update timezone plugin type definition ([#1221](#1221)) ([34cfb92](34cfb92))
@iamkun
Copy link
Owner

iamkun commented Dec 5, 2020

🎉 This issue has been resolved in version 1.9.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@iamkun iamkun added the released label Dec 5, 2020
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.9.7](iamkun/dayjs@v1.9.6...v1.9.7) (2020-12-05)

### Bug Fixes

* add duration.format to format a Duration ([#1202](iamkun/dayjs#1202)) ([9a859a1](iamkun/dayjs@9a859a1))
* Add function handling for relativeTime.future and relativeTime.past ([#1197](iamkun/dayjs#1197)) ([ef1979c](iamkun/dayjs@ef1979c))
* avoid install installed plugin ([#1214](iamkun/dayjs#1214)) ([a92eb6c](iamkun/dayjs@a92eb6c))
* avoid memory leak after installing a plugin too many times ([b8d2e32](iamkun/dayjs@b8d2e32))
* fix diff bug when UTC plugin enabled ([#1201](iamkun/dayjs#1201)) ([9544ed2](iamkun/dayjs@9544ed2)), closes [#1200](iamkun/dayjs#1200)
* fix startOf/endOf bug in timezone plugin ([#1229](iamkun/dayjs#1229)) ([eb5fbc4](iamkun/dayjs@eb5fbc4))
* fix utc plugin diff edge case ([#1187](iamkun/dayjs#1187)) ([971b3d4](iamkun/dayjs@971b3d4))
* update customParseFormat plugin to parse 2-digit offset ([#1209](iamkun/dayjs#1209)) ([b56936a](iamkun/dayjs@b56936a)), closes [#1205](iamkun/dayjs#1205)
* Update timezone plugin type definition ([#1221](iamkun/dayjs#1221)) ([34cfb92](iamkun/dayjs@34cfb92))
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.9.7](iamkun/dayjs@v1.9.6...v1.9.7) (2020-12-05)

### Bug Fixes

* add duration.format to format a Duration ([#1202](iamkun/dayjs#1202)) ([9a859a1](iamkun/dayjs@9a859a1))
* Add function handling for relativeTime.future and relativeTime.past ([#1197](iamkun/dayjs#1197)) ([ef1979c](iamkun/dayjs@ef1979c))
* avoid install installed plugin ([#1214](iamkun/dayjs#1214)) ([a92eb6c](iamkun/dayjs@a92eb6c))
* avoid memory leak after installing a plugin too many times ([b8d2e32](iamkun/dayjs@b8d2e32))
* fix diff bug when UTC plugin enabled ([#1201](iamkun/dayjs#1201)) ([9544ed2](iamkun/dayjs@9544ed2)), closes [#1200](iamkun/dayjs#1200)
* fix startOf/endOf bug in timezone plugin ([#1229](iamkun/dayjs#1229)) ([eb5fbc4](iamkun/dayjs@eb5fbc4))
* fix utc plugin diff edge case ([#1187](iamkun/dayjs#1187)) ([971b3d4](iamkun/dayjs@971b3d4))
* update customParseFormat plugin to parse 2-digit offset ([#1209](iamkun/dayjs#1209)) ([b56936a](iamkun/dayjs@b56936a)), closes [#1205](iamkun/dayjs#1205)
* Update timezone plugin type definition ([#1221](iamkun/dayjs#1221)) ([34cfb92](iamkun/dayjs@34cfb92))
@StefanoMagrassi
Copy link

@iamkun it looks like it is broken again: https://codesandbox.io/s/silly-dewdney-cjnrbm?file=/src/index.ts

version 1.11.5

@rubyhat
Copy link

rubyhat commented Nov 3, 2022

@iamkun it looks like it is broken again: https://codesandbox.io/s/silly-dewdney-cjnrbm?file=/src/index.ts

version 1.11.5

I have the same problem in version 1.11.6

@shell
Copy link

shell commented Feb 2, 2023

My tests show that versions 1.9.7 and 1.9.8 got it patched. Next release 1.10.0 broke this again and it hasn't been working since.

@iamkun please fix when you have time, because it is valid ISO 8601 case

@crieggalder
Copy link

Seeing a regression that may be related:

Our Supabase backend (Postgres as a service) returns dates in this format: 2023-02-20T17:45:00.477622+00:00.
For some reason .fromNow() still works as expected, but .format() chokes on these dates. E.g.

dayjs('2023-02-20T17:45:00.477622+00:00').format('YYYY') // "Undefined is not an object (evaluating 'i[n]')"

splashwizard pushed a commit to splashwizard/tracking-time that referenced this issue Oct 21, 2024
## [1.9.7](iamkun/dayjs@v1.9.6...v1.9.7) (2020-12-05)

### Bug Fixes

* add duration.format to format a Duration ([#1202](iamkun/dayjs#1202)) ([9a859a1](iamkun/dayjs@9a859a1))
* Add function handling for relativeTime.future and relativeTime.past ([#1197](iamkun/dayjs#1197)) ([ef1979c](iamkun/dayjs@ef1979c))
* avoid install installed plugin ([#1214](iamkun/dayjs#1214)) ([a92eb6c](iamkun/dayjs@a92eb6c))
* avoid memory leak after installing a plugin too many times ([b8d2e32](iamkun/dayjs@b8d2e32))
* fix diff bug when UTC plugin enabled ([#1201](iamkun/dayjs#1201)) ([9544ed2](iamkun/dayjs@9544ed2)), closes [#1200](iamkun/dayjs#1200)
* fix startOf/endOf bug in timezone plugin ([#1229](iamkun/dayjs#1229)) ([eb5fbc4](iamkun/dayjs@eb5fbc4))
* fix utc plugin diff edge case ([#1187](iamkun/dayjs#1187)) ([971b3d4](iamkun/dayjs@971b3d4))
* update customParseFormat plugin to parse 2-digit offset ([#1209](iamkun/dayjs#1209)) ([b56936a](iamkun/dayjs@b56936a)), closes [#1205](iamkun/dayjs#1205)
* Update timezone plugin type definition ([#1221](iamkun/dayjs#1221)) ([34cfb92](iamkun/dayjs@34cfb92))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants