示例
luxon 3.5.0: In Luxon 3, specifying system as the zone always resolves to the host system zone and ignores Settings.defaultZone.
已验证示例 — npm luxon 3.5.0: In Luxon 3, specifying system as the zone always resolves to the host system zone and ignores Settings.defaultZone. contract 在 node…
sha256:8d2b9cea97100faf30a7e95f31f32596bffe04c0d763bba5e9456ea2cd4918ab
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 3
- 构建过它的签名密钥
- 3
声明的环境
node linux x64 node node npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-17 |
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-09-08 |
案例
HOW- 目标
- In Luxon 3, specifying system as the zone always resolves to the host system zone and ignores Settings.defaultZone.
- 符号
-
- DateTime.setZone
- Settings.defaultZone
- 环境
- node
- 创建时间
- 2026-08-17T01:57:28Z
契约
- DateTime setZone('system') returns a SystemZone instance with type system rather than inheriting Settings.defaultZone.
- DateTime setZone('default') must be explicitly used to inherit the custom Settings.defaultZone.
文件
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
源代码
# Luxon Zone Resolution Notes
## Search Results
Calling search_known_solution returned two compatible samples for luxon:
1. Show that `DateTime.local` in luxon does not accept a unit object in its arguments.
2. Do timezone-aware date math without the day drifting.
This sample addresses a different major version 3 breaking change regarding zone specifier resolution.
## Version Divergence and Failure Mode
In Luxon 1.x and 2.x, configuring `Settings.defaultZone` caused `DateTime.now().setZone('system')` to resolve to that default zone (producing an `iana` zone instance). In Luxon 3.x, `'system'` strictly resolves to the host environment system zone (`SystemZone`, with type `'system'`) and ignores `Settings.defaultZone`. Inheriting the custom default zone in Luxon 3.x requires explicitly passing `'default'`.
In Luxon 2.x, contracts asserting that `setZone('system')` produces a `'system'` zone type fail loudly with an `AssertionError` because `dt.zone.type` evaluates to `'iana'`.
{"case":{"believed":"Setting Settings.defaultZone overrides the zone for DateTime instances created or converted with the system zone specifier.","caseId":"case:sha256:2abe2d355e2d0a79529b9d45a749ac77133384bba4deaedc5f5255d1b120eb19","contract":["DateTime setZone('system') returns a SystemZone instance with type system rather than inheriting Settings.defaultZone.","DateTime setZone('default') must be explicitly used to inherit the custom Settings.defaultZone."],"goal":"In Luxon 3, specifying system as the zone always resolves to the host system zone and ignores Settings.defaultZone.","kind":"HOW","packages":["pkg:npm/luxon@3.5.0"],"schemaVersion":1,"symbols":["DateTime.setZone","Settings.defaultZone"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/luxon@3.5.0"],"schemaVersion":1,"symbols":["DateTime.setZone","Settings.defaultZone"],"verifierAdapter":"node-typescript@1"}
{
"name": "luxon-v3-contract",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "luxon-v3-contract",
"version": "1.0.0",
"dependencies": {
"luxon": "3.5.0"
}
},
"node_modules/luxon": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.5.0.tgz",
"integrity": "sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==",
"license": "MIT",
"engines": {
"node": ">=12"
}
}
}
}
{
"name": "luxon-v3-contract",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"luxon": "3.5.0"
}
}
import assert from 'node:assert';
import { DateTime, Settings } from 'luxon';
const systemZoneName = DateTime.now().setZone('system').zoneName;
const customDefault = systemZoneName === 'America/New_York' ? 'Europe/London' : 'America/New_York';
Settings.defaultZone = customDefault;
const dtSystem = DateTime.now().setZone('system');
assert.strictEqual(
dtSystem.zone.type,
'system',
"In Luxon 3, DateTime.setZone('system') returns a zone of type 'system', ignoring Settings.defaultZone"
);
assert.notStrictEqual(
dtSystem.zoneName,
customDefault,
"In Luxon 3, DateTime.setZone('system') does not resolve to the configured Settings.defaultZone"
);
const dtDefault = DateTime.now().setZone('default');
assert.strictEqual(
dtDefault.zone.type,
'iana',
"In Luxon 3, DateTime.setZone('default') resolves to the configured IANA default zone"
);
assert.strictEqual(
dtDefault.zoneName,
customDefault,
"In Luxon 3, DateTime.setZone('default') inherits the value set in Settings.defaultZone"
);