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

Timezone 'Europe/London' is not working properly #2126

Open
logeshwaran1998 opened this issue Nov 15, 2022 · 4 comments
Open

Timezone 'Europe/London' is not working properly #2126

logeshwaran1998 opened this issue Nov 15, 2022 · 4 comments

Comments

@logeshwaran1998
Copy link

Hi team,
I have used (dayjs().tz('Europe/London').startOf('year').format('YYYY-MM-DD')) method in my project. This method is not working properly with this tz. The output should be (2022-01-01) but I received (2021-01-01).

Can anyone suggest the solution? and Why this issue was occurred?. Thanks in advance

Note: Other timezones are working fine and same method working fine in codesandbox.

@BePo65
Copy link
Contributor

BePo65 commented Nov 16, 2022

tested it with pr #2118 and the result was what was expected - '2022-01-01'

@obviyus
Copy link

obviyus commented Dec 14, 2022

We just faced this bug while working with multiple timezones. Is there a workaround for this while we wait for the PR to get merged?

@AplusKminus
Copy link

AplusKminus commented Feb 1, 2023

We discovered this issue during development. Here is a simple test that demonstrates the problem.

    it("should NOT fail", () => {
        const date1 = dayjs.tz("2020-01-25", "Europe/London").startOf("day");
        const date2 = dayjs.tz("2020-01-25", "Europe/London").startOf("day");

        expect(date1.isSame(date2)).toBe(true);
        expect(date1.isSame(date2, "day")).toBe(true);
    });

Luckily in our case we could work around this issue by not applying .startOf("day") before the comparison, bur rather through the comparison.

    it("this works", () => {
        const date1 = dayjs.tz("2020-01-25", "Europe/London");
        const date2 = dayjs.tz("2020-01-25", "Europe/London");

        expect(date1.isSame(date2, "day")).toBe(true);
    });

@obviyus maybe this is also a viable workaround for you?

@obviyus
Copy link

obviyus commented Feb 6, 2023

@AplusKminus our situation is slightly different where I wish to have the time at the start of the day. We ended up moving to using https://github.com/js-joda/js-joda instead.

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

No branches or pull requests

4 participants