Temporal

为处理日期和时间提供标准对象和函数。「Provides standard objects and functions for working with dates and times.」

Github stars Tracking Chart

Temporal

为处理日期和时间提供标准对象和功能。

状态

本提案目前处于 第 3 阶段,并由 Richard Gibson、Bradley Farias 和 Daniel Ehrenberg 对第 3 阶段进行了审查。

注意:虽然这个提案的 API 预计不会改变,但在 IETF 对时区/日历字符串序列化格式进行标准化之前,这个提案的实现者必须不发布未标记的 Temporal 实现。请参阅 #1450 了解更新。

这个提案现在在 ECMAScript 引擎实现者手中,所以对 API 的修改要求非常高。尽管如此,由于 JS 引擎中实现的反馈,可能会发生变化。按照第三阶段提案的惯例,对规范的编辑修改和对规范、polyfill、测试和文档的 bug 修复也在进行中。在第三阶段,还在增加额外的测试和文档内容。

Champions

概述/动机

日期是 ECMAScript 中长期存在的痛点。本文提出的 Temporal,是一个全局对象,它作为一个顶层命名空间(像 Math 一样),为 ECMAScript 语言带来了现代的日期/时间 API。关于动机的详细分解,请看:修复 JavaScript 日期

原则

规格文本

规格文本可以在 这里 找到。

Polyfill

我们建立了一个 非生产性的 polyfill 来验证这个建议。该提案的支持者将很快开始生产就绪的填充物的工作,一旦开始,它将被链接到这里。如果您正在开发一个不同的生产质量的polyfill,请告诉我们,我们也可以把它链接到这里。

当查看 参考文档 时,polyfill 会自动加载到您的浏览器中,所以您可以通过打开浏览器的开发者工具控制台来试用它。

注意:我们鼓励您对polyfill进行实验,但不要在生产中使用它! API可能会根据实现者的反馈而改变,并且当前的非生产型polyfill对于某些操作来说非常缓慢。

文档

参考文档和示例可以在 这里 找到。

这里 可以找到一本食谱来帮助你入门和了解Temporal的来龙去脉。


Main metrics

Overview
Name With Ownertc39/proposal-temporal
Primary LanguageHTML
Program languageHTML (Language Count: 3)
PlatformWeb browsers
License:Other
所有者活动
Created At2017-03-12 01:50:08
Pushed At2025-06-23 20:36:08
Last Commit At
Release Count10
Last Release Name0.9.0 (Posted on 2021-07-09 08:59:02)
First Release Name0.1.0 (Posted on 2020-06-15 15:18:04)
用户参与
Stargazers Count3.6k
Watchers Count95
Fork Count167
Commits Count3.8k
Has Issues Enabled
Issues Count1382
Issue Open Count37
Pull Requests Count1638
Pull Requests Open Count7
Pull Requests Close Count86
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Temporal

Provides standard objects and functions for working with dates and times.

Status

This proposal is currently Stage 3 and was reviewed for Stage 3 by Richard Gibson, Bradley Farias, and Daniel Ehrenberg.

NOTE: Although this proposal's API is not expected to change, implementers of this proposal MUST NOT ship unflagged Temporal implementations until IETF standardizes timezone/calendar string serialization formats. See #1450 for updates.

This proposal is now in the hands of ECMAScript engine implementers, so the bar for making API changes is extremely high.
Nonetheless, changes may occur as the result of feedback from implementation in JS engines.
Editorial changes to the spec and bug fixes to the spec, polyfill, tests, and docs are also ongoing, as is customary for Stage 3 proposals.
Additional tests and documentation content are also being added during Stage 3.

Champions

Overview / Motivation

Date has been a long-standing pain point in ECMAScript.
This proposes Temporal, a global Object that acts as a top-level namespace (like Math), that brings a modern date/time API to the ECMAScript language.
For a detailed breakdown of motivations, see:
Fixing JavaScript Date

Principles:

  • All Temporal objects are immutable.
  • Date values can be represented in local calendar systems (why?), but they should be convertable to and from the Proleptic Gregorian Calendar.
  • All time-of-day values are based on a standard 24-hour clock.
  • Leap seconds are not represented.

Specification Text

The specification text can be found here.

Polyfill

A non-production polyfill was built to validate this proposal.
The champions of this proposal will soon start work on a production-ready polyfill, and once it's started it will be linked here.
If you're working on a different production-quality polyfill, let us know and we can link it here too!

When viewing the reference documentation, the polyfill is automatically loaded in your browser, so you can try it out by opening your browser's developer tools console.

NOTE: We encourage you to experiment with the polyfill, but don't use it in production!
The API may change based on feedback from implementers, and the current non-production polyfill is very slow for some operations.

Documentation

Reference documentation and examples can be found here.

A cookbook to help you get started and learn the ins and outs of Temporal is available here