question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with converting to Europe/London timezone

See original GitHub issue

Describe the bug I have dates formatted in ISO-8601 format and use dayjs to convert them to different timezones. Conversion works file for all cases except for “Europe/London”. It seems the issue might apply to all timezones that match UTC one.

What i do is i use dayjs in an angular app where i have a custom pipe doing the following in the function:

dayjs.extend(utc);
dayjs.extend(timezone);
return dayjs(value).tz(tz).locale(locale).format(pattern);

where value is 2020-11-06T19:27:08Z and tz Europe/London and pattern DD MMM, HH:mm a

In this case i would expect 06 Nov, 19:27 pm but i get 06 Nov, 17:27 pm. If i change timezone to something that does not match UTC like Europe/Athens or Europe/Paris the conversion works fine.

Information

  • Day.js Version 1.9.6
  • OS: [e.g. iOS]
  • Browser Chrome/Firefox

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
anzapcommented, Nov 15, 2020

Ok managed to get a better view on why this is happening. Problem seems to be timezone with locale usage. Check this link https://runkit.com/embed/gaitj4v88l8d

If i put .locale() call after .timezone() call i get the issue. If i put .locale() call before .timezone() call i get the correct time, but output is not localized based on locale. This is easier to verify with the greek locale el.

3reactions
AlexGrafecommented, Nov 21, 2020

Thanks @anzap. Everything works with enough duct tape I guess. Thanks for the workaround 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues when converting from Europe/London time to UTC
Googling tells me that UTC should be an hour behind Europe/London time but when I tried to write a unit test to verify...
Read more >
Converting times between time zones - Microsoft Learn
This article explains how to convert times from one time zone to another and convert DateTimeOffset values that have limited time zone awareness ......
Read more >
Converting time zones in R: tips, tricks and pitfalls
(By the way, GMT isn't always the same as London time: GMT is not affected by daylight savings.) So the problem of converting...
Read more >
Time Zone Converter
Time Zone Converter. Converter Results: 10:04:26 Wednesday December 28, 2022 in GMT. Daylight Saving Time is not in effect on this date/time in...
Read more >
Europe/London: Time Zone in United Kingdom, Current local ...
Time Zone Converter (Time Difference Calculator). Compare the local time of two timezones, countries or cities of the world. Europe/London ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found