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

Add datetimeIn for timezone offset #3

Open
meduzen opened this issue Mar 15, 2021 · 1 comment
Open

Add datetimeIn for timezone offset #3

meduzen opened this issue Mar 15, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@meduzen
Copy link
Owner

meduzen commented Mar 15, 2021

datetimeIn(date, timezone, optionalPrecision) could take a local time and shift it to another timezone.

Use case: “what time is it now in [somewhere far away]?”

How we could make it work:

  1. Read the UTC values of the provided Date object.
  2. Do something with these values (sorry, should go to bed) and use Intl.DateTimeFormat to transform the timezone to the specified location, e.g.:
new Intl.DateTimeFormat('en-GB', {
  dateStyle: 'short',
  timeStyle: 'long',
  timeZone: 'America/New_York'
}).format(date); // '03/05/2021, 17:28:22 GMT-4'
  1. Compute timezones difference by comparing the GMT values and/or reparsing the output of 2.
  2. ??

(Also, check what Moments and others are doing.)

@meduzen meduzen added the enhancement New feature or request label Mar 15, 2021
@meduzen meduzen changed the title Add datetimeIn for timezone offset. Add datetimeIn for timezone offset Mar 18, 2021
@meduzen
Copy link
Owner Author

meduzen commented May 3, 2021

Issue updated.

@meduzen meduzen changed the title Add datetimeIn for timezone offset Add datetimeIn for timezone offset Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant