Exemple
dayjs 1.11.19: Parse and format a UTC timestamp with dayjs without a timezone surprise
Échantillon vérifié pour npm dayjs 1.11.19: Parse and format a UTC timestamp with dayjs without a timezone surprise. Le contrat s'est exécuté sur node 22 …
sha256:30fbf9d211e6d215664a742dcf35432e3326364594c16f7db37a7dec5eff3695
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 7
- Clés de signature qui l’ont compilé
- 3
Environnement déclaré
node 22 linux x64 node 22 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-13 |
| node 22 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-13 |
| node 22 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-13 |
| node 22 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-13 |
| node 22 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-13 |
| 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:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-09-07 |
Cas
HOW- Objectif
- Parse and format a UTC timestamp with dayjs without a timezone surprise
- Paquets
- Symboles
-
- dayjs
- dayjs.extend
- utc
- Environnement
- node 22
- Créé
- 2026-08-13T12:02:53Z
Contrat
- extend dayjs with the utc plugin
- parse an ISO timestamp as UTC
- assert formatting stays UTC regardless of the host timezone
- assert add/diff arithmetic stays exact
Fichiers
- csx.json
- package-lock.json
- package.json
- src/index.mjs
- test/contract.mjs
Code source
{"case":{"caseId":"case:sha256:1f004f0d62d6e33b64de66ad707c2382c16d5a60cce003a846b6028442032c78","constraints":{"moduleSystem":"esm","runtime":"node"},"contract":["extend dayjs with the utc plugin","parse an ISO timestamp as UTC","assert formatting stays UTC regardless of the host timezone","assert add/diff arithmetic stays exact"],"goal":"Parse and format a UTC timestamp with dayjs without a timezone surprise","kind":"HOW","packages":["pkg:npm/dayjs@1.11.19"],"schemaVersion":1,"symbols":["dayjs","dayjs.extend","utc"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","moduleSystem":"esm","os":"linux","packageManager":"npm","runtime":"node","runtimeVersion":"22","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/dayjs@1.11.19"],"schemaVersion":1,"symbols":["dayjs","dayjs.extend","utc"],"verifierAdapter":"node-typescript@1"}
{
"name": "csx-sample-dayjs-utc-format",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "csx-sample-dayjs-utc-format",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"dayjs": "1.11.19"
}
},
"node_modules/dayjs": {
"version": "1.11.19",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz",
"integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==",
"license": "MIT"
}
}
}
{
"name": "csx-sample-dayjs-utc-format",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"dayjs": "1.11.19"
}
}
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc.js';
// The utc plugin must be registered once before dayjs.utc() exists;
// forgetting it is the usual "dayjs.utc is not a function" error.
dayjs.extend(utc);
export function formatUTC(iso, pattern = 'YYYY-MM-DD HH:mm:ss') {
return dayjs.utc(iso).format(pattern);
}
export function addHoursUTC(iso, hours) {
return dayjs.utc(iso).add(hours, 'hour').toISOString();
}
import { strict as assert } from 'node:assert';
// A non-UTC host timezone is exactly the condition this sample is about.
process.env.TZ = 'Asia/Seoul';
const { formatUTC, addHoursUTC } = await import('../src/index.mjs');
assert.equal(formatUTC('2026-08-13T01:02:03Z'), '2026-08-13 01:02:03');
assert.equal(addHoursUTC('2026-08-13T23:00:00Z', 2), '2026-08-14T01:00:00.000Z');
console.log('CONTRACT PASS: dayjs utc plugin formats in UTC under TZ=Asia/Seoul');