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

utcToZonedTime should not be doing any conversion when "UTC" is passed in as the time zone #250

Open
TheSonOfThomp opened this issue Sep 5, 2023 · 1 comment

Comments

@TheSonOfThomp
Copy link

TheSonOfThomp commented Sep 5, 2023

I was debugging, and wrote the following jest test:

describe('utcToZonedTime', () => {
  const date = new Date(Date.UTC(2023, 8, 1));

  test('converting to UTC has no effect', () => {
    const utc = utcToZonedTime(date, 'UTC');
    expect(utc.toISOString()).toEqual(date.toISOString());
  });
});

This test fails with the following result

  ● utcToZonedTime › converting to UTC has no effect

    expect(received).toEqual(expected) // deep equality

    Expected: "2023-09-01T00:00:00.000Z"
    Received: "2023-09-01T04:00:00.000Z"

My local time zone is -4:00, which makes sense if this is adding 4 to convert to "UTC". But shouldn't this function assume the provided date is in UTC already, and not the client time zone?

@IB21-A
Copy link

IB21-A commented Jan 17, 2024

I just discovered this same issue while writing a test. It doesn't matter what format I pass it, even an ISO formatted string like '2023-09-01T00:00:00.000Z', it always assumes the provided date is my local time zone. I hope there are some plans to address this

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

2 participants