{"_id":"@adaskothebeast/http-params-processor-value-to-nodatime","_rev":"4-d6e69ccee4437a6312983d9fd1466366","name":"@adaskothebeast/http-params-processor-value-to-nodatime","dist-tags":{"latest":"12.0.0"},"versions":{"10.0.0":{"name":"@adaskothebeast/http-params-processor-value-to-nodatime","version":"10.0.0","_id":"@adaskothebeast/http-params-processor-value-to-nodatime@10.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"dist":{"shasum":"e201805de111cad973432549b862e51b2a7442f0","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-nodatime/-/http-params-processor-value-to-nodatime-10.0.0.tgz","fileCount":23,"integrity":"sha512-OSG6Yuwr19iatv8E5FMjYyzU1CBMmCB9c4YsqmfzGRGw+L/X2UokktKA85btzYouOjo89XhZVRt0v6SmdWL+BQ==","signatures":[{"sig":"MEQCIEzmWEC+ZfumoJ3VB0QjhXrSZGD/asFPT/EpdNW72tFfAiB4VoIAz5BrEkGfzYYz4odoXpEdIoKkLY8RhSKJfg72Og==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36153},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"1e61d6323f67038b9af916e4f3d263a73fe76497","_npmUser":{"name":"adasko","email":"adaskothebeast@gmail.com"},"_npmVersion":"11.6.2","description":"> Transform complex TypeScript objects into query parameters for Angular, Axios, Fetch, and more","directories":{},"sideEffects":false,"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"peerDependencies":{"@adaskothebeast/http-params-processor-core":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-value-to-nodatime_10.0.0_1768077323351_0.6110216755221181","host":"s3://npm-registry-packages-npm-production"}},"11.0.0":{"name":"@adaskothebeast/http-params-processor-value-to-nodatime","version":"11.0.0","author":{"url":"https://github.com/adaskothebeast","name":"Adam Pluciński","email":"adaskothebeast@gmail.com"},"license":"MIT","_id":"@adaskothebeast/http-params-processor-value-to-nodatime@11.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"dist":{"shasum":"774345f9345d93dd391e1f4d88ac7631290690d8","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-nodatime/-/http-params-processor-value-to-nodatime-11.0.0.tgz","fileCount":12,"integrity":"sha512-UBOXveeOh7oJy4Zric6mcChypQ8A5faRfTuk9dH1R67TSy8L63pZm8owaRwKAnS/u5DY55s8PKLuiSvLEL1Fbg==","signatures":[{"sig":"MEYCIQDRNk4fT6pBv6iu98INkNRnGklleNi4jPAub7znzfhQugIhAPxC68hvvxuoyS4dAfVT5IgYCnFlXxP+WkRaM9igWAiU","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-to-nodatime@11.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":45783},"main":"./index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:7d2c5aef-bde7-4177-9a6f-7094c27c4490"}},"repository":{"url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git","type":"git"},"_npmVersion":"11.6.2","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-value-to-nodatime_11.0.0_1768758174991_0.7489090359632362","host":"s3://npm-registry-packages-npm-production"}},"11.1.0":{"name":"@adaskothebeast/http-params-processor-value-to-nodatime","version":"11.1.0","author":{"url":"https://github.com/adaskothebeast","name":"Adam Pluciński","email":"adaskothebeast@gmail.com"},"license":"MIT","_id":"@adaskothebeast/http-params-processor-value-to-nodatime@11.1.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"dist":{"shasum":"66bfeb057a5870a73b51f0a49b7f9d8389ebe6ae","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-nodatime/-/http-params-processor-value-to-nodatime-11.1.0.tgz","fileCount":12,"integrity":"sha512-dxk8l0Xth6+PkvHx5BM5NS7Xfkgfl99fLAN0BpkRuL2wfcVFwR2UTyWT8dCr7qUxEj4k0mKRtscFZHROsncT0Q==","signatures":[{"sig":"MEQCIH+gUAEtnqqk9xsB4UHOmf32Za+17tkPmucKcZNyV8DGAiBvVTJ6PXN64G8oTgrJ6XDeyleFc+AEO7QtGNr+UpKYTg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-to-nodatime@11.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":45783},"main":"./index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:7d2c5aef-bde7-4177-9a6f-7094c27c4490"}},"repository":{"url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git","type":"git"},"_npmVersion":"11.6.2","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-value-to-nodatime_11.1.0_1768758931846_0.12032918334599918","host":"s3://npm-registry-packages-npm-production"}},"12.0.0":{"name":"@adaskothebeast/http-params-processor-value-to-nodatime","version":"12.0.0","description":"NodaTime compatible date, duration and period output strategies for HttpParamsProcessor.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","nodatime","dotnet","duration","period"],"license":"MIT","author":{"name":"Adam Pluciński","email":"adaskothebeast@gmail.com","url":"https://github.com/adaskothebeast"},"repository":{"type":"git","url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git"},"bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","type":"module","sideEffects":false,"main":"./index.cjs","module":"./index.js","types":"./index.d.ts","peerDependencies":{"@adaskothebeast/http-params-processor-core":"^12.0.0"},"exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"gitHead":"73d31a6c26a6f2819f6c98aabb36659532e4cdd0","_id":"@adaskothebeast/http-params-processor-value-to-nodatime@12.0.0","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-af/6D7eXGkC+QvgFv4OKQ74GmWHYdMuyeQz9EWnDLIsi4HdlH3CBNzEzDj5xjsQVJfL+vTRDoHDamSwt5bSQ8g==","shasum":"b6fe2ddfc098e24ab2210de2bca6b887e3bdc347","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-nodatime/-/http-params-processor-value-to-nodatime-12.0.0.tgz","fileCount":13,"unpackedSize":19896,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDGS1lVPLWCDgoosjfKp5e1eCzYp6LuoxqY4qBcaI21qwIgFRF50ysFhuSIXWQ0gyc8IBifzJf5D2EsDAUDHNgo3xY="}]},"_npmUser":{"name":"adasko","email":"adaskothebeast@gmail.com"},"directories":{},"maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/http-params-processor-value-to-nodatime_12.0.0_1785236401082_0.4881915620395021"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-10T20:35:23.265Z","modified":"2026-07-28T11:00:01.440Z","10.0.0":"2026-01-10T20:35:23.507Z","11.0.0":"2026-01-18T17:42:55.145Z","11.1.0":"2026-01-18T17:55:31.986Z","12.0.0":"2026-07-28T11:00:01.228Z"},"bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"author":{"name":"Adam Pluciński","email":"adaskothebeast@gmail.com","url":"https://github.com/adaskothebeast"},"license":"MIT","homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","repository":{"type":"git","url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git"},"maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"readme":"# 🧭 @adaskothebeast/http-params-processor-value-to-nodatime\n\n**NodaTime friendly output strategies for [HttpParamsProcessor](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor): dates, durations and periods shaped the way a .NET NodaTime backend parses them (`2024-01-01T00:00:00.000Z`, `PT26H`, `P1Y6M`).**\n\n[![npm](https://img.shields.io/npm/v/%40adaskothebeast%2Fhttp-params-processor-value-to-nodatime?color=cb3837&logo=npm)](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-nodatime)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\nCore only, zero runtime dependencies. ESM + CJS. `sideEffects: false`.\n\n---\n\n## 📦 Install\n\n```bash\nnpm i @adaskothebeast/http-params-processor-value-to-nodatime @adaskothebeast/http-params-processor-core\n```\n\n---\n\n## 🎯 What it does\n\nThese are **value-to** strategies: the second half of the conversion pipeline. Pair each of them with a **value-from** strategy (`-value-from-luxon`, `-value-from-dayjs`, `-value-from-moment`, `-value-from-js-joda`, or the `DefaultDateValueFromStrategy` from `core`) using `createValueConverter`.\n\n| Class                             | Serializes           | Example output             |\n| --------------------------------- | -------------------- | -------------------------- |\n| `NodaTimeDateValueToStrategy`     | `Date`               | `2024-01-01T00:00:00.000Z` |\n| `NodaTimeDurationValueToStrategy` | `DurationComponents` | `PT1H30M`, `PT26H`         |\n| `NodaTimePeriodValueToStrategy`   | `PeriodComponents`   | `P1Y6M`, `P2W`             |\n\nThe split mirrors NodaTime's own type system: `Instant`/`OffsetDateTime` for a point in time, `Duration` for an exact elapsed time, `Period` for a calendar amount. Sending a calendar shape where the server expects an exact time (or the other way round) is the usual source of NodaTime parse failures, so pick the strategy that matches the target property.\n\n---\n\n## ⚡ Usage\n\n```ts\nimport { DefaultDateValueFromStrategy, ParamsProcessor, createValueConverter } from '@adaskothebeast/http-params-processor-core';\nimport { LuxonDateTimeValueFromStrategy, LuxonDurationValueFromStrategy } from '@adaskothebeast/http-params-processor-value-from-luxon';\nimport { NodaTimeDateValueToStrategy, NodaTimeDurationValueToStrategy, NodaTimePeriodValueToStrategy } from '@adaskothebeast/http-params-processor-value-to-nodatime';\nimport { DateTime, Duration } from 'luxon';\n\nconst processor = new ParamsProcessor({\n  valueConverters: [\n    createValueConverter(new LuxonDateTimeValueFromStrategy(), new NodaTimeDateValueToStrategy()),\n    // register the period converter first if plain objects should be calendar amounts\n    createValueConverter(new LuxonDurationValueFromStrategy(), new NodaTimePeriodValueToStrategy()),\n    createValueConverter(new LuxonDurationValueFromStrategy(), new NodaTimeDurationValueToStrategy()),\n    // keep native Dates working too\n    createValueConverter(new DefaultDateValueFromStrategy(), new NodaTimeDateValueToStrategy()),\n  ],\n});\n\nprocessor.process('p', {\n  at: DateTime.fromISO('2024-01-01T00:00:00Z'),\n  window: Duration.fromObject({ hours: 1, minutes: 30 }),\n});\n// [['p.at', '2024-01-01T00:00:00.000Z'], ['p.window', 'PT1H30M']]\n```\n\n---\n\n## 🎛️ Options and formats\n\nNo constructor options - every output shape is fixed.\n\n**Dates** use `Date.prototype.toISOString()`: always UTC (`Z`), always with milliseconds. That is exactly what NodaTime's `InstantPattern.ExtendedIso` and `Instant.FromDateTimeOffset` round-trip, so no server side pattern configuration is needed.\n\n**Durations** are time only. NodaTime's `Duration` has no calendar fields, so the strategy normalizes before writing `PT[n]H[n]M[n]S`:\n\n- `days` are folded into hours as `hours + days * 24` (a NodaTime `Duration` day is always exactly 24 hours, unlike a `Period` day),\n- `milliseconds` are folded into the seconds field as a decimal fraction (`milliseconds / 1000`),\n- `years`, `months` and `weeks` are **not** part of a `Duration` and are dropped,\n- zero components are omitted, and an all-zero duration becomes `PT0S`.\n\n| `DurationComponents` input          | Output    |\n| ----------------------------------- | --------- |\n| `{ hours: 1, minutes: 30 }`         | `PT1H30M` |\n| `{ days: 1, hours: 2 }`             | `PT26H`   |\n| `{ seconds: 1, milliseconds: 500 }` | `PT1.5S`  |\n| `{ milliseconds: 250 }`             | `PT0.25S` |\n| `{}` / all zeros                    | `PT0S`    |\n\n**Periods** are calendar based and are written verbatim as `P[n]Y[n]M[n]W[n]D` with no normalization at all, because a NodaTime `Period` keeps its units separate. An empty period becomes `P0D`.\n\n| `PeriodComponents` input  | Output  |\n| ------------------------- | ------- |\n| `{ years: 1, months: 6 }` | `P1Y6M` |\n| `{ weeks: 2 }`            | `P2W`   |\n| `{ months: 18 }`          | `P18M`  |\n| `{}` / all zeros          | `P0D`   |\n\n---\n\n## 📤 Output examples\n\n```text\np.at=2024-01-01T00%3A00%3A00.000Z\np.window=PT1H30M\np.uptime=PT26H\np.precise=PT1.5S\np.contract=P1Y6M\np.sprint=P2W\np.empty=P0D\n```\n\n---\n\n## ⚠️ Edge cases\n\n- `NodaTimeDateValueToStrategy.canHandle` rejects **invalid dates** (`new Date('invalid')`), so they fall through to the next converter instead of producing `Invalid Date`.\n- Duration and period detection are **structural**, and the two strategies are deliberately disjoint:\n  - `NodaTimeDurationValueToStrategy.canHandle` needs at least one numeric `days`/`hours`/`minutes`/`seconds`/`milliseconds` key, so `{ years: 1, months: 2 }` is rejected.\n  - `NodaTimePeriodValueToStrategy.canHandle` accepts an object only when **every** key is `years`/`months`/`weeks`/`days` (or has an `undefined` value) and at least one of them is a number, so `{ hours: 1 }` is rejected.\n  - `{ days: 3 }` matches **both** (it is a valid period and a valid duration). Whichever converter you register first claims it, so register the period converter first if bare day counts are calendar amounts in your API.\n- `{ years: 1, hours: 2 }` is handled as a duration and serializes to `PT2H`: the `years` field is silently dropped, because NodaTime cannot express years in a `Duration`. Split such values into a separate period parameter.\n- `weeks` are dropped by the duration strategy as well; convert weeks to days (or hours) before serializing if the target property is a `Duration`.\n- Fractional components are written verbatim (`{ hours: 1.5 }` → `PT1.5H`). NodaTime parses fractional seconds, but not fractional hours or minutes, so normalize first when the value can be fractional.\n- Because `days` fold into hours, a duration that spans a DST transition is **not** wall-clock corrected. Use `NodaTimePeriodValueToStrategy` (a NodaTime `Period`, applied in a calendar) when you need \"same time next day\" semantics.\n- `PeriodComponents` cannot express time-of-day; objects that carry hours/minutes/seconds are treated as durations instead.\n\n---\n\n## 🔗 Related packages\n\n- Inputs: [`-value-from-luxon`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-luxon), [`-value-from-dayjs`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-dayjs), [`-value-from-moment`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-moment), [`-value-from-js-joda`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-js-joda)\n- Other outputs: [`-value-to-iso`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-iso), [`-value-to-unix-timestamp`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-unix-timestamp), [`-value-to-ms-timestamp`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-ms-timestamp), [`-value-to-date-fns`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-date-fns)\n- Engine: [`-core`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-core)\n\nFull matrix and adapter recipes: [main README](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor#readme).\n\n---\n\n## 📄 License\n\n[MIT](./LICENSE) © Adam Pluciński\n","readmeFilename":"README.md","description":"NodaTime compatible date, duration and period output strategies for HttpParamsProcessor.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","nodatime","dotnet","duration","period"]}