{"_id":"@adaskothebeast/http-params-processor-value-to-date-fns","_rev":"4-ec9631e0cba1424a2aea25ae2ba78627","name":"@adaskothebeast/http-params-processor-value-to-date-fns","dist-tags":{"latest":"12.0.0"},"versions":{"10.0.0":{"name":"@adaskothebeast/http-params-processor-value-to-date-fns","version":"10.0.0","_id":"@adaskothebeast/http-params-processor-value-to-date-fns@10.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"dist":{"shasum":"29fa420c5bd366a8a6a1eacf506c129d11daf8fd","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-date-fns/-/http-params-processor-value-to-date-fns-10.0.0.tgz","fileCount":15,"integrity":"sha512-W1E2QdY7rH3TgC7eKpr5moplZzbSwI3qz2M5hZglVpdiwS3Q/ME1oaXDNzLi1u4UoInohluL665T852mcsFLkw==","signatures":[{"sig":"MEUCICxpjLi0Fo3EzlmAyHctJ6CS+KZOklHWzlQ9xaSbdzlFAiEA4FDFe29sp5fM8egYImDT3BgT3J3V5d5iJUo7rLNgq50=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27930},"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":{"date-fns":"*","@adaskothebeast/http-params-processor-core":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-value-to-date-fns_10.0.0_1768077270590_0.4959942550066607","host":"s3://npm-registry-packages-npm-production"}},"11.0.0":{"name":"@adaskothebeast/http-params-processor-value-to-date-fns","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-date-fns@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":"08275c917d14a2e1dc7b3b06b37ed46ca5a229ca","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-date-fns/-/http-params-processor-value-to-date-fns-11.0.0.tgz","fileCount":8,"integrity":"sha512-WcV5a804VVFTCEC0FsHnBGoPOX4p8Li4sDTVwnV1z1qOfpsQc7+u2EjLbi1AwHhyFTJCcyGMViZHGeAQllzvmA==","signatures":[{"sig":"MEUCIQC248A3bcs3ijsIChRPOq4qvvvWv6v4BjD+j3aOj9xzoAIgKFjkQoejXbVYo6M44u8Y6GSFiTLpBcpC5xFv0vJ5tQQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-to-date-fns@11.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":81624},"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:761f3fd2-a8c9-4dab-997f-ecf2805bfd3c"}},"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-date-fns_11.0.0_1768758182010_0.8034648379643214","host":"s3://npm-registry-packages-npm-production"}},"11.1.0":{"name":"@adaskothebeast/http-params-processor-value-to-date-fns","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-date-fns@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":"de04a5ce1cf8448b5b0f14f724d3db61cd70a88c","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-date-fns/-/http-params-processor-value-to-date-fns-11.1.0.tgz","fileCount":8,"integrity":"sha512-IVJgZS4Fw6hZ6VyhFsWHZynuOfZ3bKo2+54uV/4NnF/ty2SbyhonSAcd6C5Wy3iU4nZkk5bP8boCuYCJ/MxpuA==","signatures":[{"sig":"MEQCICdeuWDZPlMI4YA9hQLALjFoVB463wbjRPH4NSZYmnbEAiAP5JJeyoCxkmuChZ9tlBTMd3w4l3llH2hplxgZI2hJSw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-to-date-fns@11.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":81624},"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:761f3fd2-a8c9-4dab-997f-ecf2805bfd3c"}},"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-date-fns_11.1.0_1768758918932_0.6848568170450069","host":"s3://npm-registry-packages-npm-production"}},"12.0.0":{"name":"@adaskothebeast/http-params-processor-value-to-date-fns","version":"12.0.0","description":"date-fns format output strategy for HttpParamsProcessor date values.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","date-fns","format","date"],"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","date-fns":"^4.4.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-date-fns@12.0.0","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-IR6BQ3oBKE9wWwiKQKm3vIev66worfc3CpQKpReCvVsW4Ba1zOg6KPhetbstWuo1Kg2iDlUDHIhaocyg9Feh7g==","shasum":"5abc4c0139b0ff0e7f4a6c55ea716c44ece26dce","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-date-fns/-/http-params-processor-value-to-date-fns-12.0.0.tgz","fileCount":9,"unpackedSize":13560,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCMRUxDtCmTBxjnAZUPNaJpMatfmgpmwLAxYmAM3oLCMwIgTFpXFdDigljbMmUaZ2MDW3rIwk9SJat5+X451DkJwO4="}]},"_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-date-fns_12.0.0_1785236322308_0.010225218938793912"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-10T20:34:30.479Z","modified":"2026-07-28T10:58:42.738Z","10.0.0":"2026-01-10T20:34:30.726Z","11.0.0":"2026-01-18T17:43:02.147Z","11.1.0":"2026-01-18T17:55:19.060Z","12.0.0":"2026-07-28T10:58:42.454Z"},"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-date-fns\n\n**Custom date formatting for [HttpParamsProcessor](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor) powered by [date-fns](https://date-fns.org/): any format token string you like, `yyyy-MM-dd` by default.**\n\n[![npm](https://img.shields.io/npm/v/%40adaskothebeast%2Fhttp-params-processor-value-to-date-fns?color=cb3837&logo=npm)](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-date-fns)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\nPeer dependencies: `date-fns ^4.4.0` plus `core`. Types ship with `date-fns`. ESM + CJS. `sideEffects: false`.\n\n---\n\n## 📦 Install\n\n```bash\nnpm i @adaskothebeast/http-params-processor-value-to-date-fns @adaskothebeast/http-params-processor-core date-fns\n```\n\n---\n\n## 🎯 What it does\n\nThis is a **value-to** strategy: the second half of the conversion pipeline. Pair it 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| `DateFnsValueToStrategy` | `Date`     | `2024-01-15` (default), `01/15/2024`, ... |\n\nUse it when the backend wants a **specific human readable shape** rather than an ISO instant or an epoch number: a date-only `yyyy-MM-dd` filter, a US style `MM/dd/yyyy` report parameter, a `yyyyMM` bucket key, and so on. Only dates are supported; durations and periods are not part of this package.\n\n---\n\n## ⚡ Usage\n\n```ts\nimport { DefaultDateValueFromStrategy, ParamsProcessor, createValueConverter } from '@adaskothebeast/http-params-processor-core';\nimport { LuxonDateTimeValueFromStrategy } from '@adaskothebeast/http-params-processor-value-from-luxon';\nimport { DateFnsValueToStrategy } from '@adaskothebeast/http-params-processor-value-to-date-fns';\nimport { DateTime } from 'luxon';\n\nconst processor = new ParamsProcessor({\n  valueConverters: [\n    createValueConverter(\n      new LuxonDateTimeValueFromStrategy(),\n      new DateFnsValueToStrategy(), // yyyy-MM-dd\n    ),\n    // keep native Dates working too\n    createValueConverter(new DefaultDateValueFromStrategy(), new DateFnsValueToStrategy()),\n  ],\n});\n\nprocessor.process('p', {\n  day: DateTime.fromISO('2024-01-15T10:30:00Z'),\n});\n// [['p.day', '2024-01-15']]\n```\n\nA different format is a constructor argument:\n\n```ts\nconst usDate = new DateFnsValueToStrategy('MM/dd/yyyy');\nusDate.serializeValue(new Date('2024-01-15T00:00:00.000Z')); // '01/15/2024'\n\nconst localDateTime = new DateFnsValueToStrategy(\"yyyy-MM-dd'T'HH:mm:ss\");\nlocalDateTime.serializeValue(new Date('2024-01-15T10:30:45.000Z'));\n// '2024-01-15T11:30:45' in UTC+1, '2024-01-15T10:30:45' in UTC\n```\n\nBecause the format lives on the instance, you can register **several converters with different formats** and let the value-from strategies decide which one claims a value, or build one processor per endpoint shape.\n\n---\n\n## 🎛️ Options and formats\n\n| Constructor parameter | Type     | Default        | Meaning                                    |\n| --------------------- | -------- | -------------- | ------------------------------------------ |\n| `formatString`        | `string` | `'yyyy-MM-dd'` | Passed straight to `format(date, pattern)` |\n\nThat single argument is the whole API. `serializeValue` calls `format(value, this.formatString)` from `date-fns` with **no options object**, which has two consequences worth knowing:\n\n- formatting happens in the **runtime local time zone**, since that is what `format` does,\n- `date-fns` options such as `locale`, `weekStartsOn`, `useAdditionalDayOfYearTokens` and `useAdditionalWeekYearTokens` cannot be forwarded. If you need locale aware month or weekday names, format the value yourself before it reaches the processor.\n\nAny Unicode token string that `date-fns` accepts works:\n\n| `formatString`          | Output for `2024-01-15T10:30:45Z` (in UTC) |\n| ----------------------- | ------------------------------------------ |\n| `yyyy-MM-dd` (default)  | `2024-01-15`                               |\n| `MM/dd/yyyy`            | `01/15/2024`                               |\n| `dd.MM.yyyy`            | `15.01.2024`                               |\n| `yyyy-MM-dd HH:mm`      | `2024-01-15 10:30`                         |\n| `yyyy-MM-dd'T'HH:mm:ss` | `2024-01-15T10:30:45`                      |\n| `yyyyMMdd`              | `20240115`                                 |\n| `yyyy-MM`               | `2024-01`                                  |\n\n---\n\n## 📤 Output examples\n\n```text\np.day=2024-01-15\np.reportDate=01%2F15%2F2024\np.bucket=2024-01\np.stampedAt=2024-01-15T10%3A30%3A45\n```\n\n---\n\n## ⚠️ Edge cases\n\n- **Local time zone, not UTC.** `format` renders wall-clock time in whatever zone the process runs in, so `2024-01-15T23:30:00Z` becomes `2024-01-16` in UTC+2 and `2024-01-15` in UTC. Pin `TZ` in CI, or convert to the intended zone before serializing (`date-fns-tz`, or the corresponding helper of your date library).\n- **Protected tokens throw.** In `date-fns` v2 and later, `YYYY`, `YY`, `D` and `DD` raise a `RangeError` telling you to use `yyyy`, `yy`, `d` or `dd`, because `Y` means week-numbering year and `D` means day of year. Since this strategy passes no options object, the escape hatches (`useAdditionalWeekYearTokens`, `useAdditionalDayOfYearTokens`) are unreachable - just use the lowercase tokens.\n- The format string is **not validated at construction time**. A bad pattern only fails when the first value is serialized, i.e. during `process`.\n- Literal text must be quoted with single quotes (`\"yyyy-MM-dd'T'HH:mm:ss\"`), otherwise letters are interpreted as tokens. A literal single quote is written as `''`.\n- `canHandle` accepts **only real `Date` instances** and rejects **invalid dates** (`new Date('invalid')`), which also keeps `format` from throwing `Invalid time value`. Strings such as `'2024-01-01'` are rejected as well and fall through to the next converter.\n- Date-only formats are **lossy**: `yyyy-MM-dd` drops the time, so a range filter built from two timestamps silently widens to whole days.\n- `date-fns` is a **peer dependency**, so the consumer controls the version, and locale or time zone helpers stay optional sub-imports that this package never pulls in.\n- If you only need a UTC ISO instant, [`-value-to-iso`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-iso) does it without any dependency.\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-nodatime`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-nodatime), [`-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)\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":"date-fns format output strategy for HttpParamsProcessor date values.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","date-fns","format","date"]}