Skip to content

Support timezone? #35

Open
Open
@jledentu

Description

@jledentu

Hi,

This adapter doesn't allow to specify a timezone when parsing/formatting dates, since, unline Luxon, date-fns options don't support timezones. There is an official complementary library, date-fns-tz, that adds functions with timezone support:

  • zonedTimeToUtc - Given a date and any time zone, returns a Date with the equivalent UTC time
  • utcToZonedTime - Get a date/time representing local time in a given time zone from the UTC date
  • getTimezoneOffset - Gets the offset in milliseconds between the time zone and UTC time
  • format - Extends date-fns/format with full time zone support
  • toDate - Can be used to create a zoned Date from a string containing an offset or IANA time zone

I wonder what is the best strategy to support timezones:

  • Create a chartjs-adapter-date-fns-tz adapter that extends this one,
  • Or add a timezone option in this adapter, then calling date-fns-tz functions (I guess we should then make the dependency optional)?

Since there is no too much logic in date adapters (i.e we just pass options to the underlying library), creating a distinct adapter may be a cleaner option?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions