{"_id":"fiscalclock","_rev":"2-4477cd2e81e52943d52b77de49d9cb8c","name":"fiscalclock","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.0-stage":{"name":"fiscalclock","version":"0.0.0-stage","_id":"fiscalclock@0.0.0-stage","stub":true,"maintainers":[{"name":"karthik-beta","email":"karthikparam10@gmail.com"}],"dist":{"shasum":"b592ac84f137c22e6d805492a1d716963657a8eb","tarball":"https://registry.npmjs.org/fiscalclock/-/fiscalclock-0.0.0-stage.tgz","fileCount":2,"integrity":"sha512-z5h/6A1bdkl/qg/tDyQXMVgXAOOLihF+Zw5d0xnGI6ztPugOH6zYPiIxZJTIKPphZc2ybEDeSCR8Kb9CfAlOww==","signatures":[{"sig":"MEYCIQCRede3CXP0efo8n7xpTaaSMyXsHG0Qm3gFSPtW/cdtAgIhAL7xCEhkszNbE8TwXWcKYh9dxaE3U1HsBtWG6E6D5twR","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":333},"_npmUser":{"name":"karthik-beta","email":"karthikparam10@gmail.com"},"description":"Temporary package placeholder for staged publishing","directories":{}},"0.1.0":{"_id":"fiscalclock@0.1.0","bugs":{"url":"https://github.com/Karthik-beta/fiscalclock/issues"},"dist":{"shasum":"afa9c6a74d6c56794988769f95b8e1d7c072cff2","tarball":"https://registry.npmjs.org/fiscalclock/-/fiscalclock-0.1.0.tgz","fileCount":14,"integrity":"sha512-ES2frRp0ky+ONFIFpsDzdHAD0BckA1V+qr9XFBmzWAKJOo02jJWFbaBrEpxu9e/AxqjYMMKPOvuAeZugX6I37g==","signatures":[{"sig":"MEUCIQCvo4C99kte5RVsp/lBSuf6qns9PYbd77xpcmOCeoc6UwIgU35QncjWDZMgYApOVJZwOfCcU/rdjpXAp+XwMtfZai0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIB4rRdaesjJ2b6qdxtnRDg18JQtP1FOvrJ4aB2Ac98BkAiEAk3DFBzRjOjDbzdG7JErW9k27uni+Y0qKHBhtgzpYmJc="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/fiscalclock@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":415416},"name":"fiscalclock","type":"module","_from":"file:npm-dist/fiscalclock-0.1.0.tgz","author":{"name":"Karthik Parameshwara"},"engines":{"node":">=22"},"exports":{".":{"node":"./dist/node.js","types":"./dist/index.d.ts","default":"./dist/web.js"}},"license":"MIT OR Apache-2.0","scripts":{"test":"node --test","build":"node scripts/build.mjs"},"version":"0.1.0","_npmUser":{"name":"karthik-beta","email":"karthikparam10@gmail.com"},"homepage":"https://github.com/Karthik-beta/fiscalclock","keywords":["fiscal","calendar","4-5-4","retail","accounting","webassembly"],"_resolved":"/home/runner/work/fiscalclock/fiscalclock/npm-dist/fiscalclock-0.1.0.tgz","_integrity":"sha512-ES2frRp0ky+ONFIFpsDzdHAD0BckA1V+qr9XFBmzWAKJOo02jJWFbaBrEpxu9e/AxqjYMMKPOvuAeZugX6I37g==","repository":{"url":"git+https://github.com/Karthik-beta/fiscalclock.git","type":"git","directory":"bindings/js"},"_npmVersion":"11.19.1","description":"Fiscal calendar engine: compute any fiscal calendar from a JSON definition","directories":{},"maintainers":[{"name":"karthik-beta","email":"karthikparam10@gmail.com"}],"sideEffects":["./dist/node.js","./dist/web.js"],"_nodeVersion":"24.22.1","_hasShrinkwrap":false,"devDependencies":{"typescript":"7.0.2","@types/node":"22.20.5"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fiscalclock_0.1.0_1793470823504_0.8991471975406243"}}},"time":{"created":"2026-10-31T18:19:27.374Z","modified":"2026-10-31T18:20:23.941Z","0.0.0-stage":"2026-10-31T18:19:27.374Z","0.1.0":"2026-10-31T18:20:23.622Z"},"description":"Fiscal calendar engine: compute any fiscal calendar from a JSON definition","maintainers":[{"name":"karthik-beta","email":"karthikparam10@gmail.com"}],"readme":"# fiscalclock for JavaScript\n\n[![npm](https://img.shields.io/npm/v/fiscalclock?label=npm)](https://www.npmjs.com/package/fiscalclock)\n[![Node.js](https://img.shields.io/node/v/fiscalclock)](https://www.npmjs.com/package/fiscalclock)\n[![Types](https://img.shields.io/npm/types/fiscalclock)](https://www.npmjs.com/package/fiscalclock)\n[![CI](https://github.com/Karthik-beta/fiscalclock/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Karthik-beta/fiscalclock/actions/workflows/ci.yml)\n[![Licence: MIT OR Apache-2.0](https://img.shields.io/badge/licence-MIT%20OR%20Apache--2.0-blue)](#licence)\n\nnpm package for [fiscalclock](https://github.com/Karthik-beta/fiscalclock), a fiscal calendar engine. You describe a fiscal calendar as a JSON definition, and the package answers questions about it: which fiscal year, quarter, period and week a date falls in, the bounds of any period, labels such as `Q4 FY2023`, and a day-by-day date dimension.\n\nThe package has no built-in calendars. Every calendar is a definition you supply, in the format specified in [`spec/definition-v1.md`](https://github.com/Karthik-beta/fiscalclock/blob/main/spec/definition-v1.md).\n\nAll computation happens in the fiscalclock Rust core, compiled to WebAssembly. The TypeScript layer only converts values, so results are identical to the Rust crate and the Python package.\n\nStatus: 0.1.0 is the first release. The definition format and API are version 1 drafts and may change before 1.0.\n\n## Install\n\n```sh\nnpm install fiscalclock\n```\n\nThe package is an ES module with TypeScript types and needs Node.js 22 or later. In Node.js it loads the WebAssembly module from disk when imported. Other environments get an entry point that fetches the module relative to its own URL with top-level `await`.\n\n## Example\n\nA 4-5-4 calendar whose year ends on the Saturday nearest 31 January:\n\n```js\nimport { FiscalCalendar } from \"fiscalclock\";\n\nconst cal = new FiscalCalendar({\n  spec_version: 1,\n  year: { type: \"week_based\", anchor: { edge: \"end\", month: 1, day: \"last\", rule: \"nearest\" } },\n  week: { starts_on: \"sunday\", numbering: \"contains_start\" },\n  subdivision: { type: \"week_pattern\", periods: [4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5, 4],\n                 quarters: [3, 3, 3, 3], extra_week: { period: 12 } },\n  naming: { default: \"fy\", schemes: { fy: { year_number: \"start\",\n            templates: { year: \"FY{yyyy}\", quarter: \"Q{q} FY{yyyy}\" } } } },\n});\n\nconst fy2023 = cal.period(\"year\", 2023);\nfy2023.start;    // \"2023-01-29\"\nfy2023.last_day; // \"2024-02-03\"\nfy2023.weeks;    // 53\n\nconst here = cal.locate(\"2024-02-03\");\ncal.format(here.quarter); // \"Q4 FY2023\"\n```\n\n## API\n\n`new FiscalCalendar(definition)` takes a JSON string or an object and throws `FiscalclockError` if the definition is invalid. Its methods are `locate`, `period`, `shift`, `parent`, `children`, `years`, `format`, `parse`, `dimension`, `dimensionCsv` and `explain`, as described in [`spec/api-v1.md`](https://github.com/Karthik-beta/fiscalclock/blob/main/spec/api-v1.md).\n\n- Periods and locations are plain objects with the keys of the core's JSON output, and dates as ISO `YYYY-MM-DD` strings. Every period is the half-open interval `[start, end_exclusive)`.\n- `callJson(op, args)` and the exported `callJson` and `validateJson` take and return JSON text exactly as the core produces it.\n- `validate(definition)` returns the validation result and does not throw.\n- `FiscalclockError` carries the stable `code`, the JSON `path`, `hint` and `details` of the first error, and `errors` holding all of them.\n\n## Dates\n\nDate arguments accept an ISO `YYYY-MM-DD` string or a `Temporal.PlainDate`. A JavaScript `Date`, and a Temporal `PlainDateTime`, `ZonedDateTime` or `Instant`, throws `FiscalclockError` with code `TIMESTAMP_REJECTED`, because the calendar day of a timestamp depends on the time zone. Convert it to a date in the time zone you mean first.\n\n## How the results are checked\n\n- 112 shared conformance vector files (4,070 cases) are run by the Rust, Python and npm test suites. Expected results come from cited sources or from independent generators, never from fiscalclock itself. See [`conformance/`](https://github.com/Karthik-beta/fiscalclock/tree/main/conformance).\n- Week-based years are checked against Python's `date.isocalendar()` for every year from 1600 to 2399, and a slow day-by-day reference implementation is compared with the core for every date from 1900 to 2200.\n- Property tests check that periods tile and nest, and that `shift` and `format`/`parse` round-trip.\n- On every push, CI runs all vectors through Rust and through the Python and npm packages on Linux, macOS and Windows and requires the outputs to match byte for byte.\n\n## Supply chain\n\nThis package is built and published by the [release workflow](https://github.com/Karthik-beta/fiscalclock/blob/main/.github/workflows/release.yml) from a version tag on `main`, after a smoke test of the built packages on Linux, macOS and Windows and the maintainer's approval. Every release file has a [build provenance attestation](https://github.com/Karthik-beta/fiscalclock/attestations). To check the `.tgz` from `npm pack fiscalclock` or the GitHub release:\n\n```sh\ngh attestation verify <file> --repo Karthik-beta/fiscalclock\n```\n\nReport vulnerabilities privately as described in [SECURITY.md](https://github.com/Karthik-beta/fiscalclock/blob/main/SECURITY.md). Changes are listed in the [changelog](https://github.com/Karthik-beta/fiscalclock/blob/main/CHANGELOG.md).\n\n## Licence\n\nLicensed under either of [Apache License, Version 2.0](https://github.com/Karthik-beta/fiscalclock/blob/main/LICENSE-APACHE) or [MIT licence](https://github.com/Karthik-beta/fiscalclock/blob/main/LICENSE-MIT), at your option.\n","readmeFilename":"README.md","homepage":"https://github.com/Karthik-beta/fiscalclock","keywords":["fiscal","calendar","4-5-4","retail","accounting","webassembly"],"repository":{"url":"git+https://github.com/Karthik-beta/fiscalclock.git","type":"git","directory":"bindings/js"},"author":{"name":"Karthik Parameshwara"},"bugs":{"url":"https://github.com/Karthik-beta/fiscalclock/issues"},"license":"MIT OR Apache-2.0"}