CodeSampleX

Sample

luxon 3.6.1

Verified sample for npm luxon 3.6.1. The contract ran on node 22 · linux alpine/x64 · docker and passed: DateTime.fromISO and DateTime.utc parse valid ISO…

sha256:38d5c0c9810bfe4131c88f37ed9af5561f12bbfc5578ad2bf290b4a358810194

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
verify pkg:npm/luxon@3.6.1
Packages
Created
2026-08-23T06:15:21Z

Contract

  1. DateTime.fromISO and DateTime.utc parse valid ISO strings and maintain date components
  2. DateTime.fromISO marks unparsable strings as invalid with unparsable reason
  3. DateTime arithmetic with plus and minus produces new instances while keeping original instances immutable
  4. DateTime startOf and endOf correctly adjust time boundaries
  5. DateTime toFormat and toISODate produce properly formatted date strings
  6. DateTime diff calculates accurate day and hour differences as Duration objects
  7. Duration fromObject converts and scales time units accurately
  8. Interval fromDateTimes creates valid intervals and accurately determines containment and overlap

Files

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

Download the source artifact (tar.gz)

Source

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 pkg:npm/luxon@3.6.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/luxon@3.6.1

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:3aec7364b28c2c07915b509889c13151e624bac5133c8554245f820ed595d7b9","contract":["DateTime.fromISO and DateTime.utc parse valid ISO strings and maintain date components","DateTime.fromISO marks unparsable strings as invalid with unparsable reason","DateTime arithmetic with plus and minus produces new instances while keeping original instances immutable","DateTime startOf and endOf correctly adjust time boundaries","DateTime toFormat and toISODate produce properly formatted date strings","DateTime diff calculates accurate day and hour differences as Duration objects","Duration fromObject converts and scales time units accurately","Interval fromDateTimes creates valid intervals and accurately determines containment and overlap"],"goal":"verify pkg:npm/luxon@3.6.1","kind":"HOW","packages":["pkg:npm/luxon@3.6.1"],"schemaVersion":1},"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","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-luxon",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-luxon",
      "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",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for luxon",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "luxon": "3.6.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/luxon@3.6.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/luxon@3.6.1"
  ]
}
src/index.js
'use strict';

const { DateTime, Duration, Interval } = require('luxon');

function parseIsoUtc(isoString) {
  return DateTime.fromISO(isoString, { zone: 'utc' });
}

function addDuration(dateTime, durationObj) {
  return dateTime.plus(durationObj);
}

function subtractDuration(dateTime, durationObj) {
  return dateTime.minus(durationObj);
}

function calculateDiff(dtEnd, dtStart, units) {
  return dtEnd.diff(dtStart, units);
}

function createInterval(dtStart, dtEnd) {
  return Interval.fromDateTimes(dtStart, dtEnd);
}

function createDuration(durationObj) {
  return Duration.fromObject(durationObj);
}

function formatCustom(dateTime, formatString) {
  return dateTime.toFormat(formatString);
}

module.exports = {
  parseIsoUtc,
  addDuration,
  subtractDuration,
  calculateDiff,
  createInterval,
  createDuration,
  formatCustom
};
test/contract.js
'use strict';

const assert = require('node:assert');
const { DateTime, Duration, Interval } = require('luxon');
const {
  parseIsoUtc,
  addDuration,
  subtractDuration,
  calculateDiff,
  createInterval,
  createDuration,
  formatCustom
} = require('../src/index.js');

// 1. DateTime creation and ISO parsing
const dtUtc = DateTime.fromISO('2026-08-23T10:30:00.000Z', { setZone: true });
assert.strictEqual(dtUtc.isValid, true, 'DateTime.fromISO should parse valid ISO strings as valid');
assert.strictEqual(dtUtc.year, 2026, 'year should match');
assert.strictEqual(dtUtc.month, 8, 'month should match');
assert.strictEqual(dtUtc.day, 23, 'day should match');
assert.strictEqual(dtUtc.hour, 10, 'hour should match');
assert.strictEqual(dtUtc.minute, 30, 'minute should match');
assert.strictEqual(dtUtc.second, 0, 'second should match');
assert.strictEqual(dtUtc.zoneName, 'UTC', 'zoneName should be UTC');

const helperDt = parseIsoUtc('2026-08-23T10:30:00.000Z');
assert.strictEqual(helperDt.isValid, true, 'parseIsoUtc should parse correctly');
assert.strictEqual(helperDt.toISO(), '2026-08-23T10:30:00.000Z', 'helperDt toISO should match');

// 2. Invalid DateTime handling
const invalidDt = DateTime.fromISO('invalid-timestamp-value');
assert.strictEqual(invalidDt.isValid, false, 'Invalid ISO string should produce an invalid DateTime');
assert.strictEqual(invalidDt.invalidReason, 'unparsable', 'Invalid reason should be unparsable');
assert.strictEqual(typeof invalidDt.invalidExplanation, 'string', 'Invalid explanation should provide details');

// 3. Immutability and Date Arithmetic (plus, minus, startOf, endOf)
const original = DateTime.utc(2026, 1, 15, 12, 0, 0);
const plusTwoDays = original.plus({ days: 2, hours: 3 });
assert.strictEqual(original.day, 15, 'Original DateTime must remain unchanged (immutable)');
assert.strictEqual(plusTwoDays.day, 17, 'plus() should correctly add days');
assert.strictEqual(plusTwoDays.hour, 15, 'plus() should correctly add hours');

const minusThreeHours = original.minus({ hours: 3 });
assert.strictEqual(minusThreeHours.hour, 9, 'minus() should correctly subtract hours');

const helperPlus = addDuration(original, { days: 5 });
assert.strictEqual(helperPlus.day, 20, 'addDuration helper should work');
const helperMinus = subtractDuration(original, { days: 5 });
assert.strictEqual(helperMinus.day, 10, 'subtractDuration helper should work');

const startOfDay = original.startOf('day');
assert.strictEqual(startOfDay.hour, 0, 'startOf day should set hour to 0');
assert.strictEqual(startOfDay.minute, 0, 'startOf day should set minute to 0');
assert.strictEqual(startOfDay.second, 0, 'startOf day should set second to 0');
assert.strictEqual(startOfDay.millisecond, 0, 'startOf day should set millisecond to 0');

const endOfMonth = original.endOf('month');
assert.strictEqual(endOfMonth.day, 31, 'endOf month in January should be 31');
assert.strictEqual(endOfMonth.hour, 23, 'endOf month should set hour to 23');
assert.strictEqual(endOfMonth.minute, 59, 'endOf month should set minute to 59');

// 4. Date formatting and ISO output
const formatted = formatCustom(original, 'yyyy-LL-dd HH:mm:ss');
assert.strictEqual(formatted, '2026-01-15 12:00:00', 'toFormat should format dates matching the pattern');
assert.strictEqual(original.toISODate(), '2026-01-15', 'toISODate should return ISO date string');

// 5. Diffing and Duration
const dtStart = DateTime.utc(2026, 1, 1, 0, 0, 0);
const dtEnd = DateTime.utc(2026, 1, 10, 12, 30, 0);
const diff = dtEnd.diff(dtStart, ['days', 'hours', 'minutes']);
assert.strictEqual(diff.isValid, true, 'diff Duration should be valid');
assert.strictEqual(diff.days, 9, 'diff days should be 9');
assert.strictEqual(diff.hours, 12, 'diff hours should be 12');
assert.strictEqual(diff.minutes, 30, 'diff minutes should be 30');

const helperDiff = calculateDiff(dtEnd, dtStart, ['days', 'hours']);
assert.strictEqual(helperDiff.days, 9, 'helper calculateDiff days should match');
assert.strictEqual(helperDiff.hours, 12.5, 'helper calculateDiff fractional hours should match');

// 6. Duration creation, manipulation, and conversion
const dur = Duration.fromObject({ hours: 2, minutes: 30 });
assert.strictEqual(dur.isValid, true, 'Duration should be valid');
assert.strictEqual(dur.as('minutes'), 150, 'dur.as(minutes) should convert 2h30m to 150');
assert.strictEqual(dur.as('hours'), 2.5, 'dur.as(hours) should convert 2h30m to 2.5');

const shifted = dur.shiftTo('seconds');
assert.strictEqual(shifted.seconds, 9000, 'shiftTo(seconds) should convert correctly');

const helperDur = createDuration({ hours: 1, minutes: 15 });
assert.strictEqual(helperDur.as('minutes'), 75, 'createDuration helper should work');

// 7. Interval creation and queries
const interval = Interval.fromDateTimes(dtStart, dtEnd);
assert.strictEqual(interval.isValid, true, 'Interval should be valid');
assert.strictEqual(interval.contains(DateTime.utc(2026, 1, 5, 0, 0, 0)), true, 'Interval should contain interior date');
assert.strictEqual(interval.contains(DateTime.utc(2025, 12, 31, 0, 0, 0)), false, 'Interval should not contain exterior date');

const helperInterval = createInterval(dtStart, dtEnd);
assert.strictEqual(helperInterval.isValid, true, 'createInterval helper should create valid interval');
assert.strictEqual(helperInterval.length('days'), 9.520833333333334, 'Interval length in days should match');

const overlappingInterval = Interval.fromDateTimes(DateTime.utc(2026, 1, 5), DateTime.utc(2026, 1, 15));
assert.strictEqual(interval.overlaps(overlappingInterval), true, 'interval.overlaps should return true for overlapping intervals');

const disjointInterval = Interval.fromDateTimes(DateTime.utc(2026, 2, 1), DateTime.utc(2026, 2, 10));
assert.strictEqual(interval.overlaps(disjointInterval), false, 'interval.overlaps should return false for disjoint intervals');

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

Origin Seeder

anonymous