Skip to content
This repository was archived by the owner on Apr 7, 2023. It is now read-only.

gilmoreorless/d3-time-temporal

 
 

Repository files navigation

d3-time-temporal

A conversion of d3-time to use the in-progress Temporal proposal instead of the legacy Date object.

⚠️ This is purely an experiment to test out the viability of the Temporal API. DO NOT USE THIS IN PRODUCTION. ⚠️

In most places I've attempted to make the minimum amount of changes to make it work, and preserve the d3 code style. The one big deviation from that goal was the creation of a factory method to make most definitions much simpler. This was only possible after converting everything to Temporal.DateTime, at which point the method definitions were much more similar and repetitive.

Differences from d3-time

  • All d3-time methods have been altered to only take and return Temporal.DateTime objects. These are abstract, immutable objects with no fixed time zone. No raw numbers representing milliseconds, no legacy Date objects.
  • Due to the abstract nature of Temporal.DateTime, all utc* methods (d3.time.utcYear(), d3.time.utcMonth(), etc.) have been made aliases of the non-UTC versions. To use Temporal.DateTime with UTC or local time (or any other time zone), call the .toInstant(timeZone) method.

See the full list of commits for step-by-step conversion details.

About

A calculator for humanity’s peculiar conventions of time.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 95.5%
  • Shell 4.5%