Exemplo
luxon 3.7.2: Show that DateTime.local treats a first object argument as options rather than calendar units and requires positional date components.
Amostra verificada para npm luxon 3.7.2: Show that DateTime.local treats a first object argument as options rather than calendar units and requires…
sha256:10f99ac67c186a7b35b30645c13de8d8089833efb1b4792bddeebae8b4818817
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 3
- Chaves de assinatura que o compilaram
- 3
Ambiente declarado
node linux x64 node node npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- Show that DateTime.local treats a first object argument as options rather than calendar units and requires positional date components.
- Pacotes
- Símbolos
-
- DateTime.local
- Settings.now
- Ambiente
- node
- Criado
- 2026-08-17T03:17:27Z
Contrato
- With `Settings.now` fixed, `DateTime.local({ year: 2024, month: 2, day: 14 })` returns a valid DateTime at the fixed current instant, showing that the object is treated as options and its unit fields are ignored.
- `DateTime.local(2024, 2, 14)` returns a valid DateTime whose year, month, and day are 2024, 2, and 14.
Arquivos
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Código-fonte
`search_known_solution` returned only non-luxon hits (yoga-layout), so no prior sample was adopted from cache.
Naive code that passes an object into `DateTime.local` fails a contract check silently (`isValid === false`) even though it looks like other `luxon` constructors.
{"case":{"believed":"A caller can create a local calendar date with `DateTime.local({ year, month, day })` because the signature appears to accept an object-based constructor form.","caseId":"case:sha256:b62018d539fc4881ffd131dcb47f453a0beb378c480e04aa91958ab822539ea7","contract":["With `Settings.now` fixed, `DateTime.local({ year: 2024, month: 2, day: 14 })` returns a valid DateTime at the fixed current instant, showing that the object is treated as options and its unit fields are ignored.","`DateTime.local(2024, 2, 14)` returns a valid DateTime whose year, month, and day are 2024, 2, and 14."],"goal":"Show that DateTime.local treats a first object argument as options rather than calendar units and requires positional date components.","kind":"HOW","packages":["pkg:npm/luxon@3.7.2"],"schemaVersion":1,"symbols":["DateTime.local","Settings.now"]},"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":["DateTime.local","Settings.now"],"verifierAdapter":"node-typescript@1"}
{
"name": "npm-luxon-api",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "npm-luxon-api",
"version": "1.0.0",
"license": "MIT-0",
"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"
}
}
}
}
{
"name": "npm-luxon-api",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"luxon": "3.7.2"
}
}
import assert from "node:assert/strict";
import { DateTime, Settings } from "luxon";
const originalNow = Settings.now;
const fixedNow = Date.UTC(2030, 5, 15, 12, 34, 56, 789);
Settings.now = () => fixedNow;
try {
const objectArgument = DateTime.local({ year: 2024, month: 2, day: 14 });
assert.equal(objectArgument.isValid, true);
assert.equal(objectArgument.toMillis(), fixedNow);
assert.equal(objectArgument.year, 2030);
const positional = DateTime.local(2024, 2, 14);
assert.equal(positional.isValid, true);
assert.equal(positional.year, 2024);
assert.equal(positional.month, 2);
assert.equal(positional.day, 14);
} finally {
Settings.now = originalNow;
}
console.log("contract passed");