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

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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);
});

오리진 시더

익명