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

Fix issue #2037 - modifying a dayjs instance created with plugin timezone in UTC corrupts it #2118

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from

Conversation

BePo65
Copy link
Contributor

@BePo65 BePo65 commented Nov 8, 2022

Using 'UTC' (or any timezone with utcOffset 0) will return a false date.

This pr also fixes the following issues

To 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.

@codecov
Copy link

codecov bot commented Nov 8, 2022

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (a947a51) 99.77% compared to head (4cb0ef7) 99.77%.

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           
Files Changed Coverage Δ
src/plugin/utc/index.js 100.00% <ø> (ø)
src/plugin/timezone/index.js 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leemoria
Copy link

leemoria commented Nov 11, 2022

hello,I ask a question, When will the latest version be released ? @iamkun @BePo65

@michaelklassen02
Copy link

Hi, when is this PR going to be merged? I'm trying to convert a repository over to DayJS and we need UTC timezone support to work in order to use it.
@iamkun @BePo65

@Kestutis
Copy link

While waiting on PR to be merged, you can just get fixed timezone plugin and use it directly
get it from - https://github.com/BePo65/dayjs/blob/fix/issue2037/src/plugin/timezone/index.js
and then import yourself from your project and extend dayjs:

import timezoneDayjs from "./local/dayjs/plugin/timezone";
dayjs.extend(timezoneDayjs);

@nkeyy0
Copy link

nkeyy0 commented Feb 27, 2023

Any updates related to this PR?

@litvinovvo
Copy link

litvinovvo commented May 5, 2023

Will it be merged any time soon? @iamkun

@zxd65885152
Copy link

hello, is there any updates with this PR?

@ateszki
Copy link

ateszki commented Aug 29, 2023

I think that with this changes it is safe to remove this previous change #1212

BePo65 and others added 3 commits September 23, 2023 16:28
## [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))
@Cheewbacca
Copy link

Any updates ?

@JugaruRobert
Copy link

Any updates about merging this? @iamkun

@jonah-ullman
Copy link

Hey there @iamkun, any updates on this? Thanks!

@andrashee
Copy link

What is blocking this PR to be merged @BePo65 @zomars? Having this fixed is crucial when working with tz and dayjs.

@BePo65
Copy link
Contributor Author

BePo65 commented Feb 29, 2024

waiting for @iamkun - I think this repository is dead. I am thinking about a fork that will merge all the important open pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet