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: +00:00 timezone bug #1678

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

DimaBur
Copy link

@DimaBur DimaBur commented Oct 31, 2021

When we have +00:00 timezone offset like 'Europe/London" dayjs gets users timezone offset, which causes incorrect time showing in different cases.

Example

Current behavior:
dayjs('2021-10-31T15:00:00+00:00').tz('Europe/London').format() // 2021-10-31T15:00:00Z

Behavior after fix:
dayjs('2021-10-31T15:00:00+00:00').tz('Europe/London').format() // 2021-10-31T15:00:00+00:00

@DimaBur DimaBur mentioned this pull request Oct 31, 2021
@codecov
Copy link

codecov bot commented Oct 31, 2021

Codecov Report

Merging #1678 (8691b58) into dev (b5a1391) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##               dev     #1678   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          179       179           
  Lines         1996      1997    +1     
  Branches       507       508    +1     
=========================================
+ Hits          1996      1997    +1     
Impacted Files Coverage Δ
src/plugin/utc/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b5a1391...8691b58. Read the comment docs.

@@ -114,7 +114,8 @@ export default (option, Dayjs, dayjs) => {

proto.valueOf = function () {
const addedOffset = !this.$utils().u(this.$offset)
? this.$offset + (this.$x.$localOffset || (new Date()).getTimezoneOffset()) : 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use ?? operator to fix this

@felipehertzer
Copy link

Hey @iamkun is there any plan to merge this fix? I'm having the same problem with Europe/London. Thanks

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

Successfully merging this pull request may close these issues.

None yet

3 participants