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

MomentJS UTC(true) Equivalent in DayJS #1078

Closed
ChildishDanbino opened this issue Sep 25, 2020 · 4 comments · Fixed by #1080
Closed

MomentJS UTC(true) Equivalent in DayJS #1078

ChildishDanbino opened this issue Sep 25, 2020 · 4 comments · Fixed by #1080
Labels

Comments

@ChildishDanbino
Copy link

ChildishDanbino commented Sep 25, 2020

We are currently in the process of migrating our legacy momentJS code over to dayJS and so far it is going well. However, we are running into issues finding the equivalent function for utc(true) from MomentJS.

Docs: https://momentjs.com/docs/#/manipulating/utc/

Per the Moment Docs: Passing true will change the time zone without changing the current time.

For Reference This is the Failing Test:

  it('startOf year with local timezone', () => {
    const result = dayjs().startOf('year').utc().toISOString();

    const momentResult = moment().startOf('year').utc(true).toISOString()

    expect(result).toEqual('2020-01-01T00:00:00.000Z'); // fails
    expect(momentResult).toEqual('2020-01-01T00:00:00.000Z'); // passes
  });

In DayJS is there an equivalent function or how we can accomplish the same goal?

@iamkun
Copy link
Owner

iamkun commented Sep 26, 2020

We do support .utcOffset(true) only at present.

And .utc(true) shares a lot the same logic. I'll implement it later soon.

@iamkun
Copy link
Owner

iamkun commented Sep 26, 2020

Added #1080, and docs updated accordingly. https://day.js.org/docs/en/manipulate/utc

@ChildishDanbino
Copy link
Author

Awesome! Thanks so much. Cant wait for this to be merged.

@iamkun
Copy link
Owner

iamkun commented Sep 28, 2020

🎉 This issue has been resolved in version 1.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants