Skip to content

Add datetimeIn for timezone offset #3

Description

@meduzen

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.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions