CodeSampleX

サンプル

luxon 3.6.1: IANAZone

検証済みサンプル — npm luxon 3.6.1: IANAZone. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: IANAZone.create creates valid IANAZone instances for valid…

sha256:c127b9fe62c451581d6a6c2cc5b5cca89ce7a1d8cd6c148ddedc95c249c82a94

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 linux 24 · ubuntu · glibc 2.39 x64 npm

検証実行環境

環境 コントラクト ステージ 実行日
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-08-23

ケース

HOW
ゴール
verify luxon.IANAZone in pkg:npm/luxon@3.6.1
パッケージ
シンボル
  • luxon.IANAZone
作成日
2026-08-23T06:17:54Z

コントラクト

  1. IANAZone.create creates valid IANAZone instances for valid IANA time zone identifiers
  2. IANAZone.isValidZone returns true for valid IANA zone identifiers and false for invalid zone identifiers
  3. IANAZone.create returns an invalid IANAZone instance with isValid false for invalid zone names without throwing
  4. IANAZone instances correctly compute UTC offsets and format offsets
  5. IANAZone instances with matching zone names are considered equal via equals method

ファイル

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

ソースアーティファクトをダウンロード (tar.gz)

ソース

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify luxon.IANAZone in pkg:npm/luxon@3.6.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/luxon@3.6.1
Demonstrate these symbols/APIs:
  - luxon.IANAZone

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:7e21cb5ae6d488e04181c13c6b02dc3eb4a7c511b94ead94a3dcb830de0ec20e","contract":["IANAZone.create creates valid IANAZone instances for valid IANA time zone identifiers","IANAZone.isValidZone returns true for valid IANA zone identifiers and false for invalid zone identifiers","IANAZone.create returns an invalid IANAZone instance with isValid false for invalid zone names without throwing","IANAZone instances correctly compute UTC offsets and format offsets","IANAZone instances with matching zone names are considered equal via equals method"],"goal":"verify luxon.IANAZone in pkg:npm/luxon@3.6.1","kind":"HOW","packages":["pkg:npm/luxon@3.6.1"],"schemaVersion":1,"symbols":["luxon.IANAZone"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/luxon@3.6.1"],"schemaVersion":1,"subject":"pkg:npm/luxon@3.6.1","symbols":["luxon.IANAZone"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-luxon-ianazone",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-luxon-ianazone",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "luxon": "3.6.1"
      }
    },
    "node_modules/luxon": {
      "version": "3.6.1",
      "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.6.1.tgz",
      "integrity": "sha512-tJLxrKJhO2ukZ5z0gyjY1zPh3Rh88Ej9P7jNrZiHMUXHae1yvI2imgOZtL1TO8TW6biMMKfTtAOoEJANgtWBMQ==",
      "license": "MIT",
      "engines": {
        "node": ">=12"
      }
    }
  }
}
package.json
{
  "name": "sample-luxon-ianazone",
  "version": "1.0.0",
  "private": true,
  "description": "verify luxon.IANAZone in pkg:npm/luxon@3.6.1",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "luxon": "3.6.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify luxon.IANAZone in pkg:npm/luxon@3.6.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/luxon@3.6.1"
  ],
  "symbols": [
    "luxon.IANAZone"
  ]
}
src/index.js
'use strict';

const { IANAZone } = require('luxon');

function createZone(zoneName) {
  return IANAZone.create(zoneName);
}

function isZoneValid(zoneName) {
  return IANAZone.isValidZone(zoneName);
}

function getZoneOffset(zoneName, timestampMs) {
  const zone = IANAZone.create(zoneName);
  if (!zone.isValid) {
    return null;
  }
  return zone.offset(timestampMs);
}

module.exports = {
  IANAZone,
  createZone,
  isZoneValid,
  getZoneOffset
};
test/contract.js
'use strict';

const assert = require('node:assert');
const { IANAZone } = require('luxon');
const { createZone, isZoneValid, getZoneOffset } = require('../src/index.js');

async function run() {
  // 1. IANAZone.create creates valid IANAZone instances for valid IANA time zone identifiers
  const ny = IANAZone.create('America/New_York');
  assert.strictEqual(ny.isValid, true, 'ny zone must be valid');
  assert.strictEqual(ny.name, 'America/New_York', 'ny zone name must match');
  assert.strictEqual(ny.type, 'iana', 'ny zone type must be iana');
  assert.strictEqual(ny.isUniversal, false, 'ny zone isUniversal must be false');

  const tokyo = IANAZone.create('Asia/Tokyo');
  assert.strictEqual(tokyo.isValid, true, 'tokyo zone must be valid');
  assert.strictEqual(tokyo.name, 'Asia/Tokyo', 'tokyo zone name must match');
  assert.strictEqual(tokyo.type, 'iana', 'tokyo zone type must be iana');
  assert.strictEqual(tokyo.isUniversal, false, 'tokyo zone isUniversal must be false');

  // 2. IANAZone.isValidZone returns true for valid IANA zone identifiers and false for invalid zone identifiers
  assert.strictEqual(IANAZone.isValidZone('America/New_York'), true, 'America/New_York must be valid');
  assert.strictEqual(IANAZone.isValidZone('Asia/Tokyo'), true, 'Asia/Tokyo must be valid');
  assert.strictEqual(IANAZone.isValidZone('UTC'), true, 'UTC must be valid');
  assert.strictEqual(IANAZone.isValidZone('Europe/Paris'), true, 'Europe/Paris must be valid');
  assert.strictEqual(IANAZone.isValidZone('Invalid/NonExistent_Zone'), false, 'Invalid zone name must return false');
  assert.strictEqual(IANAZone.isValidZone(''), false, 'Empty string must return false');

  assert.strictEqual(IANAZone.isValidSpecifier('America/New_York'), true, 'America/New_York must be valid specifier');
  assert.strictEqual(IANAZone.isValidSpecifier(123), false, 'Number must not be valid specifier');

  // 3. IANAZone.create returns an invalid IANAZone instance with isValid false for invalid zone names without throwing
  const invalid = IANAZone.create('Invalid/NonExistent_Zone');
  assert.strictEqual(invalid.isValid, false, 'invalid zone isValid must be false');
  assert.strictEqual(invalid.name, 'Invalid/NonExistent_Zone', 'invalid zone name must match input');
  assert.strictEqual(invalid.type, 'iana', 'invalid zone type must still be iana');
  assert.strictEqual(Number.isNaN(invalid.offset(0)), true, 'invalid zone offset should be NaN');

  // 4. IANAZone instances correctly compute UTC offsets and format offsets
  const utc = IANAZone.create('UTC');
  assert.strictEqual(utc.isValid, true, 'UTC zone must be valid');
  assert.strictEqual(utc.offset(0), 0, 'UTC offset at timestamp 0 must be 0');
  assert.strictEqual(utc.formatOffset(0, 'narrow'), '+0', 'UTC formatOffset narrow must be +0');

  // Asia/Tokyo has fixed UTC+9 offset (540 minutes)
  assert.strictEqual(tokyo.offset(0), 540, 'Tokyo offset at timestamp 0 must be 540 minutes');
  assert.strictEqual(tokyo.formatOffset(0, 'short'), '+09:00', 'Tokyo formatOffset short must be +09:00');
  assert.strictEqual(tokyo.formatOffset(0, 'narrow'), '+9', 'Tokyo formatOffset narrow must be +9');

  // 5. IANAZone instances with matching zone names are considered equal via equals method
  const ny2 = IANAZone.create('America/New_York');
  assert.strictEqual(ny.equals(ny2), true, 'Same IANAZone instances must be equal');
  assert.strictEqual(ny.equals(tokyo), false, 'Different IANAZone instances must not be equal');
  assert.strictEqual(ny.equals(invalid), false, 'Valid and invalid zones must not be equal');

  // 6. Helper functions in src/index.js
  const helperZone = createZone('Asia/Tokyo');
  assert.strictEqual(helperZone.isValid, true, 'helper createZone should return valid zone');
  assert.strictEqual(isZoneValid('Asia/Tokyo'), true, 'helper isZoneValid should return true for valid zone');
  assert.strictEqual(isZoneValid('Invalid/Zone'), false, 'helper isZoneValid should return false for invalid zone');
  assert.strictEqual(getZoneOffset('Asia/Tokyo', 0), 540, 'helper getZoneOffset should return 540 for Tokyo');
  assert.strictEqual(getZoneOffset('Invalid/Zone', 0), null, 'helper getZoneOffset should return null for invalid zone');

  console.log('Contract tests passed successfully.');
}

run().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

オリジンシーダー

匿名