-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix issue #2037 - modifying a dayjs instance created with plugin timezone in UTC corrupts it #2118
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev #2118 +/- ##
=======================================
Coverage 99.77% 99.77%
=======================================
Files 183 183
Lines 2262 2265 +3
Branches 641 641
=======================================
+ Hits 2257 2260 +3
Misses 5 5
☔ View full report in Codecov by Sentry. |
While waiting on PR to be merged, you can just get fixed timezone plugin and use it directly import timezoneDayjs from "./local/dayjs/plugin/timezone";
dayjs.extend(timezoneDayjs); |
Any updates related to this PR? |
Will it be merged any time soon? @iamkun |
hello, is there any updates with this PR? |
I think that with this changes it is safe to remove this previous change #1212 |
## [1.11.9](iamkun/dayjs@v1.11.8...v1.11.9) (2023-07-01) ### Bug Fixes * Add null to min and max plugin return type ([iamkun#2355](iamkun#2355)) ([62d9042](iamkun@62d9042)) * check if null passed to objectSupport parser ([iamkun#2175](iamkun#2175)) ([013968f](iamkun@013968f)) * dayjs.diff improve performance ([iamkun#2244](iamkun#2244)) ([33c80e1](iamkun@33c80e1)) * dayjs(null) throws error, not return dayjs object as invalid date ([iamkun#2334](iamkun#2334)) ([c79e2f5](iamkun@c79e2f5)) * objectSupport plugin causes an error when null is passed to dayjs function (closes [iamkun#2277](iamkun#2277)) ([iamkun#2342](iamkun#2342)) ([89bf31c](iamkun@89bf31c)) * Optimize format method ([iamkun#2313](iamkun#2313)) ([1fe1b1d](iamkun@1fe1b1d)) * update Duration plugin add/subtract take into account days in month ([iamkun#2337](iamkun#2337)) ([3b1060f](iamkun@3b1060f)) * update MinMax plugin 1. ignore the 'null' in args 2. return the only one arg ([iamkun#2330](iamkun#2330)) ([3c2c6ee](iamkun@3c2c6ee))
## [1.11.10](iamkun/dayjs@v1.11.9...v1.11.10) (2023-09-19) ### Bug Fixes * Add Korean Day of Month with ordinal ([iamkun#2395](iamkun#2395)) ([dd55ee2](iamkun@dd55ee2)) * change back fa locale to the Gregorian calendar equivalent ([iamkun#2411](iamkun#2411)) ([95e9458](iamkun@95e9458)) * duration plugin - MILLISECONDS_A_MONTH const calculation ([iamkun#2362](iamkun#2362)) ([f0a0b54](iamkun@f0a0b54)) * duration plugin getter get result 0 instead of undefined ([iamkun#2369](iamkun#2369)) ([061aa7e](iamkun@061aa7e)) * fix isDayjs check logic ([iamkun#2383](iamkun#2383)) ([5f3f878](iamkun@5f3f878)) * fix timezone plugin to get correct locale setting ([iamkun#2420](iamkun#2420)) ([4f45012](iamkun@4f45012)) * **locale:** add meridiem in `ar` locale ([iamkun#2418](iamkun#2418)) ([361be5c](iamkun@361be5c)) * round durations to millisecond precision for ISO string ([iamkun#2367](iamkun#2367)) ([890a17a](iamkun@890a17a)) * sub-second precisions need to be rounded at the seconds field to avoid adding floats ([iamkun#2377](iamkun#2377)) ([a9d7d03](iamkun@a9d7d03)) * update $x logic to avoid plugin error ([iamkun#2429](iamkun#2429)) ([2254635](iamkun@2254635)) * Update Slovenian locale for relative time ([iamkun#2396](iamkun#2396)) ([5470a15](iamkun@5470a15)) * update uzbek language translation ([iamkun#2327](iamkun#2327)) ([0a91056](iamkun@0a91056))
Removed default value for input parameter 'options', as getDateTimeFormat is never called without an options parameter; so this case cannot be tested.
'timezone name' is an internal field of dayjs (dayjs.$x.$timezone, while 'tz.offsetName' is "official" name of the timezone returned by Intl.DateTimeFormat
905967d
to
4cb0ef7
Compare
Any updates ? |
Any updates about merging this? @iamkun |
Hey there @iamkun, any updates on this? Thanks! |
waiting for @iamkun - I think this repository is dead. I am thinking about a fork that will merge all the important open pr. |
Patch for 1.11.11:
|
Using 'UTC' (or any timezone with utcOffset 0) will return a false date.
This pr also fixes the following issues
.add()
,.subtract()
, etc.) a dayjs instance created in UTC corrupts it #2037.month()
resets date property to1
when in +00:00 UTC timezone #1860To fix problems with date strings containing an offset, this solution has to differentiate between date strings with offset and one without that.
To differentiate a date only string (e.g. yy-mm-dd) from a date string with negative 2-digit offset (hour offset zz, e.g. yy-mm-zz) the changed code requires at least 8 characters before the offset (i.e. yy-mm-dd-zz).
This will not solve all possible format strings available by the CustomParseFormat, but should give no problems in real world applications.