Temporal

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

  • 所有者: tc39/proposal-temporal
  • 平台: Web browsers
  • 許可證: Other
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

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的来龙去脉。


主要指標

概覽
名稱與所有者tc39/proposal-temporal
主編程語言HTML
編程語言HTML (語言數: 3)
平台Web browsers
許可證Other
所有者活动
創建於2017-03-12 01:50:08
推送於2025-06-23 20:36:08
最后一次提交
發布數10
最新版本名稱0.9.0 (發布於 2021-07-09 08:59:02)
第一版名稱0.1.0 (發布於 2020-06-15 15:18:04)
用户参与
星數3.6k
關注者數95
派生數167
提交數3.8k
已啟用問題?
問題數1382
打開的問題數37
拉請求數1638
打開的拉請求數7
關閉的拉請求數86
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

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