CodeSampleX

Beispiel

luxon 3.7.2: Handle the Luxon 3 major revision switch where the 'system' zone strictly targets the host operating system zone rather than Settings.defaultZone and 'default' must be used to track the configured default zone.

Verifiziertes Beispiel für npm luxon 3.7.2: Handle the Luxon 3 major revision switch where the 'system' zone strictly targets the host operating system zone…

sha256:987b2b10535353b41b868e879713086cc13b579f48946a42ada763c26ecf0b2a

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
3
Signaturschlüssel, die es gebaut haben
3
Deklarierte Umgebung node linux x64 node node npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
Handle the Luxon 3 major revision switch where the 'system' zone strictly targets the host operating system zone rather than Settings.defaultZone and 'default' must be used to track the configured default zone.
Pakete
Symbole
  • Settings.defaultZone
  • DateTime.fromISO
  • DateTime.prototype.setZone
  • Info.normalizeZone
  • SystemZone
Umgebung
node
Erstellt
2026-08-17T01:57:36Z

Contract

  1. When Settings.defaultZone is overridden, Info.normalizeZone('system') and DateTime.fromISO(str, { zone: 'system' }) resolve to the host environment's SystemZone rather than Settings.defaultZone, while 'default' resolves to Settings.defaultZone instead of creating an invalid DateTime.
  2. Info.normalizeZone('system') equals SystemZone.instance and does not equal Settings.defaultZone when defaultZone is changed
  3. Info.normalizeZone('default') equals Settings.defaultZone and is valid
  4. DateTime.fromISO with zone 'system' produces a valid DateTime with zoneName equal to SystemZone.instance.name rather than Settings.defaultZone
  5. DateTime.fromISO with zone 'default' produces a valid DateTime with zoneName equal to Settings.defaultZone
  6. DateTime#setZone('system') resets zone to SystemZone.instance.name while DateTime#setZone('default') resets zone to Settings.defaultZone

Dateien

  • NOTES.md
  • csx.json
  • package-lock.json
  • package.json
  • test/contract.mjs

Quellartefakt herunterladen (tar.gz)

Quelltext

NOTES.md
# Luxon Zone Resolution

`search_known_solution` returned no existing samples for `luxon` (only compatible matches for other libraries such as chrono and date-fns).

On Luxon 2.x, passing `'default'` as a zone specifier fails loudly by returning an invalid `DateTime` with an unsupported zone error, whereas specifying `'system'` fails silently with a green build by inheriting the configured `Settings.defaultZone` rather than the host operating system's timezone.
csx.json
{"case":{"believed":"Configuring Settings.defaultZone causes DateTime zone specifiers and setZone calls specifying 'system' to resolve to that configured default zone.","caseId":"case:sha256:518a85f2493ab560e5846d7096ce1e18653fbc0677fec18140c2d43aef740782","contract":["When Settings.defaultZone is overridden, Info.normalizeZone('system') and DateTime.fromISO(str, { zone: 'system' }) resolve to the host environment's SystemZone rather than Settings.defaultZone, while 'default' resolves to Settings.defaultZone instead of creating an invalid DateTime.","Info.normalizeZone('system') equals SystemZone.instance and does not equal Settings.defaultZone when defaultZone is changed","Info.normalizeZone('default') equals Settings.defaultZone and is valid","DateTime.fromISO with zone 'system' produces a valid DateTime with zoneName equal to SystemZone.instance.name rather than Settings.defaultZone","DateTime.fromISO with zone 'default' produces a valid DateTime with zoneName equal to Settings.defaultZone","DateTime#setZone('system') resets zone to SystemZone.instance.name while DateTime#setZone('default') resets zone to Settings.defaultZone"],"goal":"Handle the Luxon 3 major revision switch where the 'system' zone strictly targets the host operating system zone rather than Settings.defaultZone and 'default' must be used to track the configured default zone.","kind":"HOW","packages":["pkg:npm/luxon@3.7.2"],"schemaVersion":1,"symbols":["Settings.defaultZone","DateTime.fromISO","DateTime.prototype.setZone","Info.normalizeZone","SystemZone"]},"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.7.2"],"schemaVersion":1,"symbols":["Settings.defaultZone","DateTime.fromISO","DateTime.prototype.setZone","Info.normalizeZone","SystemZone"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "npm-luxon-version",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-luxon-version",
      "version": "1.0.0",
      "license": "ISC",
      "dependencies": {
        "luxon": "^3.7.2"
      }
    },
    "node_modules/luxon": {
      "version": "3.7.2",
      "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.7.2.tgz",
      "integrity": "sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==",
      "license": "MIT",
      "engines": {
        "node": ">=12"
      }
    }
  }
}
package.json
{
  "name": "luxon-version-sample",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "luxon": "3.7.2"
  }
}
test/contract.mjs
import assert from 'node:assert';
import { DateTime, Settings, Info, SystemZone } from 'luxon';

// Pick a target zone that is guaranteed to differ from the host environment's system zone
const hostSystemZone = SystemZone.instance.name;
const targetZone = hostSystemZone === 'America/New_York' ? 'Asia/Tokyo' : 'America/New_York';

// Configure Settings.defaultZone to the target zone
Settings.defaultZone = targetZone;

// 1. Info.normalizeZone('system') resolves to the host SystemZone, NOT Settings.defaultZone
const normSystem = Info.normalizeZone('system');
assert.strictEqual(
  normSystem.equals(SystemZone.instance),
  true,
  "Info.normalizeZone('system') must return SystemZone.instance"
);
assert.strictEqual(
  normSystem.equals(Info.normalizeZone(targetZone)),
  false,
  "Info.normalizeZone('system') must not match the overridden Settings.defaultZone"
);

// 2. Info.normalizeZone('default') resolves to Settings.defaultZone and is valid
const normDefault = Info.normalizeZone('default');
assert.strictEqual(
  normDefault.isValid,
  true,
  "Info.normalizeZone('default') must be valid in Luxon 3+"
);
assert.strictEqual(
  normDefault.equals(Info.normalizeZone(targetZone)),
  true,
  "Info.normalizeZone('default') must match Settings.defaultZone"
);

// 3. DateTime.fromISO with { zone: 'system' } resolves to host SystemZone
const dtFromSystem = DateTime.fromISO('2023-01-01T12:00:00', { zone: 'system' });
assert.strictEqual(dtFromSystem.isValid, true);
assert.strictEqual(
  dtFromSystem.zoneName,
  hostSystemZone,
  "DateTime.fromISO with zone: 'system' must use host system timezone"
);

// 4. DateTime.fromISO with { zone: 'default' } resolves to Settings.defaultZone
const dtFromDefault = DateTime.fromISO('2023-01-01T12:00:00', { zone: 'default' });
assert.strictEqual(dtFromDefault.isValid, true);
assert.strictEqual(
  dtFromDefault.zoneName,
  targetZone,
  "DateTime.fromISO with zone: 'default' must use Settings.defaultZone"
);

// 5. DateTime#setZone('system') switches to host SystemZone, whereas setZone('default') switches to Settings.defaultZone
const dt = DateTime.fromISO('2023-01-01T12:00:00', { zone: 'UTC' });
const dtSwitchedSystem = dt.setZone('system');
assert.strictEqual(
  dtSwitchedSystem.zoneName,
  hostSystemZone,
  "setZone('system') must resolve to SystemZone"
);

const dtSwitchedDefault = dtSwitchedSystem.setZone('default');
assert.strictEqual(
  dtSwitchedDefault.zoneName,
  targetZone,
  "setZone('default') must resolve to Settings.defaultZone"
);

Ursprungs-Seeder

csx-seed