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
Modifying (.add()
, .subtract()
, etc.) a dayjs instance created in UTC corrupts it
#2037
Comments
I could reproduce the issue; working on a solution / pr. |
@BePo65 found any solution for this? Thanks. |
Yes I tried every combination and found that the problem is the utc time zone (even as gmt e.a.) I am working on it for the last 2 weeks, but i could not yet solve all combinations. At the moment I just have to fix the .tz('UTC') variant. Please be patient as it will take me for sure a few more days; but I won't surrender 😃 |
@BePo65 this gives different output shouldn't we use utc implementation when timezone has offset of zero?
|
good idea; trying to use it in my pr. |
Setting timezone explicitly
dayjs.tz(0, 'UTC').format()
'1970-01-01T00:00:00Z'
- Result'1970-01-01T00:00:00Z'
- Expecteddayjs.tz(0, 'UTC').add(0,'minutes').format()
'1969-12-31T23:00:00Z'
- Result'1970-01-01T00:00:00Z'
- Expecteddayjs.tz(0, 'UTC').add(1,'minutes').format()
'1969-12-31T23:01:00Z'
- Result'1970-01-01T00:01:00Z'
- ExpectedSetting default timezone
The above results are identical, when omitting
'UTC'
and setting UTC as default:dayjs.tz.setDefault('UTC')
dayjs.tz(0).format()
'1970-01-01T00:00:00Z'
- Result'1970-01-01T00:00:00Z'
- Expecteddayjs.tz(0).add(0,'minutes').format()
'1969-12-31T23:00:00Z'
- Result'1970-01-01T00:00:00Z'
- Expecteddayjs.tz(0).add(1,'minutes').format()
'1969-12-31T23:01:00Z'
- Result'1970-01-01T00:01:00Z'
- ExpectedInformation
The text was updated successfully, but these errors were encountered: