Workers で Temporal API が利用可能に
原題: The Temporal API is now available in Workers
changelog / DevTool / Workers / 2026/12/01 09:00 JST
Workers で、日付・時刻・タイムゾーンを扱う新しい JavaScript 標準 API「Temporal」が利用可能になった。タイムゾーン間の変換やカレンダーに即した日付計算ができ、Moment.js や Luxon、date-fns といった日付ライブラリをバンドルしなくて済む。互換性日付 2026-12-01 以降の Worker で有効になり、それより古い設定では compatibility flag「temporal」の追加で使える。リクエストから検出した訪問者のタイムゾーンに合わせて時刻を表示するなど、日時処理の多い Worker のコードがすっきりする。日付まわりのバグに悩まされてきた開発者にはうれしい標準化だ。
出典サイトで原文を開く → 出典サイトの説明: Workers now support Temporal, the modern JavaScript API for dates, times, and time zones.
Workers now support the Temporal API ↗︎ , the modern JavaScript standard for dates and times. You can convert between time zones, do calendar-correct date arithmetic, and work with plain dates and times, without bundling a date library such as Moment.js, Luxon, or date-fns. Temporal will be turned on for Workers with a compatibility date of 2026-12-01 or later. To use it with an earlier compatibility date, add the temporal compatibility flag: { “$schema” : ”./node_modules/wrangler/config-schema.json” , “compatibility_flags” : [ “temporal” ] } compatibility_flags = [ “temporal” ] This example shows the time a meeting starts in the visitor’s time zone, using the time zone Cloudflare detects for the request: src/index.js js export default { async fetch ( request ) { const timeZone = request.cf?.timezone ?? “UTC” ; const meeting = Temporal.ZonedDateTime. from ( “2026-12-15T09:30[America/New_York]” , ); const local = meeting. withTimeZone (timeZone); return new Response ( The meeting starts at ${ local . toPlainTime () } on ${ local . toPlainDate () } (${ timeZone }). , ); }, }; src/index.ts ts export default { async fetch ( request ) : Promise < Response > { const timeZone = request.
出典: 公式ページ