# Time API

**URL:** <https://es.discourse.group/t/time-api/674>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [March 1, 2021, 3:58pm UTC](https://es.discourse.group/t/time-api/674 "2021-03-01T15:58:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nin-jin](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/nin-jin/32/638_2.png) [@nin-jin](https://es.discourse.group/u/nin-jin)\
**Post date:** [March 1, 2021, 3:58pm UTC](https://es.discourse.group/t/time-api/674/1 "2021-03-01T15:58:48Z")

</div>

# `Date` API

[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)

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

[https://tc39.es/proposal-temporal/docs/index.html](https://tc39.es/proposal-temporal/docs/index.html)

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](https://github.com/hyoo-ru/mam_mol/tree/master/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](https://gist.github.com/nin-jin/1ec7cba8119f86113ffe8fe3cb21573a)

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [March 1, 2021, 4:10pm UTC](https://es.discourse.group/t/time-api/674/2 "2021-03-01T16:10:20Z")

</div>

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.
