Time API

Date API


Current engines supports Date API, that:

  • Date instances are mutable. It's bad practivce for value type.
  • It has bloat inconsistent API.
  • It represents only time moments, but doesn't support other time types declared in ISO8601.
  • It doesn't support parsing and serializing by custom pattern.
  • It doesn't support conversion between different time zones.

Temporal API


Some engines supports new proposal, but:

  • It has a hard to remember and use API with tons of classes and methods.
  • It doesn't support parsing and serializing by custom pattern.
  • It hasn't full ISO8601 support (like "hour+minute" or "year+weaknumber").
  • It doesn't support time intervals.

Time API

I propose API like $mol_time, that:

  • Very simple.
  • Easy to remember.
  • Consistent.
  • Supports time moments, durations and intervals.
  • Represents all ISO8601 variants.
  • Supports parsing and serializing by custom pattern.

More info in gist: Time JS Proposal.md · GitHub

Temporal is stage 2 - no engines support it yet that I’m aware of - but if you have feedback about that proposal, please file an issue on the proposal repo. Temporal is already the new date and time APIs, and it’s exceedingly unlikely anything else would be viable at this point.