Skip to content

Add time zone support #5186

Closed
Closed
@benmccann

Description

@benmccann

We should add time zone option that let's the user specify which timezone they'd like to use.

Things this could affect:

  • We could have one time zone for parsing data and one used for formatting labels and tooltips (e.g. timestamps are provided in UTC, but you'd like to display in Eastern timezone)
  • Also used when we're calculating major ticks / auto-ticks and try to align to the start of a minute, day, hour, etc. But when the start of the day is depends on the time zone.
  • In some cases we may be able to determine the timezone the user would like to use from the labels they've specified (e.g. +0000)
  • Unit tests are currently flaky because they depend on the timezone they're being run in

Unfortunately JavaScript's time zone support is pretty bad natively. E.g. there's no way to create a Date object in a given timezone. Your only options are local system time or UTC time. We probably want to use only UTC dates or timestamps internally and convert to the proper time zone when needed for the cases listed above.

We would either need library support or would need to implement ourselves. In either case I think we should use Intl.DateTimeFormat APIs. We already get lots of complaints about the size of Moment.js (#4303) and moment-timezone is even larger, so I think we should avoid using it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions