{"_id":"@adaskothebeast/http-params-processor-value-to-unix-timestamp","_rev":"4-50f5e22582d70cfadcc8d5a5bcbd8c56","name":"@adaskothebeast/http-params-processor-value-to-unix-timestamp","dist-tags":{"latest":"12.0.0"},"versions":{"10.0.0":{"name":"@adaskothebeast/http-params-processor-value-to-unix-timestamp","version":"10.0.0","_id":"@adaskothebeast/http-params-processor-value-to-unix-timestamp@10.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"dist":{"shasum":"5c02efb084f41b19175c04e5237557ae115a7767","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-unix-timestamp/-/http-params-processor-value-to-unix-timestamp-10.0.0.tgz","fileCount":15,"integrity":"sha512-BkwB0CkU/y+OkEOtmbtV3GSA2UiH3ErqOzPiK10mD5/+jDv9WNp6nLCYAhh4BodRY9t7y84RvNJED7YdwW3p3g==","signatures":[{"sig":"MEUCIFLvPx3JsPBu/XvWQxTmHOA+XsjFNlMgHL2O7gf150vuAiEAgoSvrRlBjZ2covuyQBX7nL7YcMVQN6a/Db1FqxiiDO8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27769},"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-unix-timestamp_10.0.0_1768077336776_0.8913937067994901","host":"s3://npm-registry-packages-npm-production"}},"11.0.0":{"name":"@adaskothebeast/http-params-processor-value-to-unix-timestamp","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-unix-timestamp@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":"77eceab9be444a81b503224b60e60d9f42008b56","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-unix-timestamp/-/http-params-processor-value-to-unix-timestamp-11.0.0.tgz","fileCount":8,"integrity":"sha512-OF0D/5F62ImLH+Y8umoJqrQMYTvTuyHXDZ+0E78whhhdYg7rMZ5UOkk3dFFgupB8taI30yyzY9/mFnr3CKgQzA==","signatures":[{"sig":"MEUCIQDKzCmsXHgOYCG4PMKI2mbH/1w4MUV/OCbKp692qfXIegIgATQ/yDFwL3PC+BDcJycN889o4yp7EuSPqBxpw2BZxEs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-to-unix-timestamp@11.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":38928},"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:6c1aded6-ea6c-4546-9dc2-056cf85d70cb"}},"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-unix-timestamp_11.0.0_1768758179305_0.4028272004289952","host":"s3://npm-registry-packages-npm-production"}},"11.1.0":{"name":"@adaskothebeast/http-params-processor-value-to-unix-timestamp","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-unix-timestamp@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":"e9087d9ec4f84a7d5c730dd77011dfddf440eaac","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-unix-timestamp/-/http-params-processor-value-to-unix-timestamp-11.1.0.tgz","fileCount":8,"integrity":"sha512-yrYwy+6Momc+T4a93vJaW8y41tFcLbSqQ00+oK9FtRoU3DbDauJvCWYoaxmvqBanmMuuyI2akWa9eiFT0KWxmg==","signatures":[{"sig":"MEQCIHPLHx6IWBqBI50PjR4Hk8uZ/nUqsq+UQUwFEuIbU6tMAiAfMptbMgBXX+leRySxItRXIjfYfXw2q8LmMEHiGx4HYA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-to-unix-timestamp@11.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":38928},"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:6c1aded6-ea6c-4546-9dc2-056cf85d70cb"}},"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-unix-timestamp_11.1.0_1768758916923_0.3004103661242403","host":"s3://npm-registry-packages-npm-production"}},"12.0.0":{"name":"@adaskothebeast/http-params-processor-value-to-unix-timestamp","version":"12.0.0","description":"Unix second timestamp output strategy for HttpParamsProcessor date values.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","unix-timestamp","epoch","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"},"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-unix-timestamp@12.0.0","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-MNVI0XKdVGC+uUgFYR7o0qvc6874/h7XljniVsCkD/VX1akw8SgQX8uOLAU82Zo2j+OumgpiWQqFxg5Yydr6sA==","shasum":"7b74067c10c148d065b0291a0a08d0855a0b5b90","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-to-unix-timestamp/-/http-params-processor-value-to-unix-timestamp-12.0.0.tgz","fileCount":9,"unpackedSize":12231,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDdN5yRzp4/Mhtd17GJesee4VksYbXXz1gnWlOg3FctsAiBaBRz20NvEIW/icOP5nOhnmRZkZxdtVejOwyyDh9NmnA=="}]},"_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-unix-timestamp_12.0.0_1785236441874_0.09523799506116837"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-10T20:35:36.715Z","modified":"2026-07-28T11:00:42.335Z","10.0.0":"2026-01-10T20:35:36.933Z","11.0.0":"2026-01-18T17:42:59.440Z","11.1.0":"2026-01-18T17:55:17.070Z","12.0.0":"2026-07-28T11:00:42.060Z"},"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-unix-timestamp\n\n**Unix timestamp output strategy for [HttpParamsProcessor](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor): dates as whole seconds since the epoch, for example `1704067200`.**\n\n[![npm](https://img.shields.io/npm/v/%40adaskothebeast%2Fhttp-params-processor-value-to-unix-timestamp?color=cb3837&logo=npm)](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-unix-timestamp)\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-unix-timestamp @adaskothebeast/http-params-processor-core\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| `UnixTimestampValueToStrategy` | `Date`     | `1704067200`   |\n\nThis is the classic POSIX / `time_t` shape used by JWT `exp`/`iat`, most REST APIs written in Go, Python, PHP or Rust, and by anything that stores time as an integer column. It carries no time zone and no sub-second precision, so the value is unambiguous but lossy.\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 { UnixTimestampValueToStrategy } from '@adaskothebeast/http-params-processor-value-to-unix-timestamp';\nimport { DateTime } from 'luxon';\n\nconst processor = new ParamsProcessor({\n  valueConverters: [\n    createValueConverter(new LuxonDateTimeValueFromStrategy(), new UnixTimestampValueToStrategy()),\n    // keep native Dates working too\n    createValueConverter(new DefaultDateValueFromStrategy(), new UnixTimestampValueToStrategy()),\n  ],\n});\n\nprocessor.process('p', {\n  from: DateTime.fromISO('2024-01-01T00:00:00Z'),\n  to: new Date('2024-06-15T14:30:45.000Z'),\n});\n// [['p.from', '1704067200'], ['p.to', '1718461845']]\n```\n\nOnly dates are covered here. If the same request also carries durations or periods, register a converter for them with [`-value-to-iso`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-iso) or [`-value-to-nodatime`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-nodatime).\n\n---\n\n## 🎛️ Options and formats\n\nNo constructor options - the output is always `Math.floor(date.getTime() / 1000)` rendered as a decimal string.\n\n| Rule              | Behaviour                                                                    |\n| ----------------- | ---------------------------------------------------------------------------- |\n| Unit              | Whole seconds since `1970-01-01T00:00:00Z`                                   |\n| Time zone         | None. The instant is absolute, so the local offset never appears in output   |\n| Sub-second digits | Discarded (`Math.floor`, so the value is rounded **down**, never rounded up) |\n| Type              | `string` (a decimal integer, no quotes, no `+` sign)                         |\n\nBecause the truncation uses `Math.floor` and not `Math.trunc`, it always moves toward the past, on both sides of the epoch:\n\n- `2024-01-01T00:00:00.999Z` → `1704067200` (the `.999` is dropped),\n- `1969-12-31T23:59:59.500Z` (`getTime()` is `-500`) → `-1`, not `0`.\n\nIf your backend expects rounding to the nearest second, round the `Date` before it reaches the processor.\n\n---\n\n## 📤 Output examples\n\n```text\np.from=1704067200          # 2024-01-01T00:00:00.000Z\np.tail=1704067200          # 2024-01-01T00:00:00.999Z, milliseconds truncated\np.to=1718461845            # 2024-06-15T14:30:45.000Z\np.epoch=0                  # 1970-01-01T00:00:00.000Z\np.moon=-14182940           # 1969-07-20T20:17:40.000Z, pre-epoch dates are negative\n```\n\n---\n\n## ⚠️ Edge cases\n\n- `canHandle` accepts **only real `Date` instances**. Strings such as `'2024-01-01'`, already-numeric timestamps such as `1704067200`, and `null` are rejected, so they fall through to the next converter and reach the default serialization untouched.\n- **Invalid dates** (`new Date('invalid')`) are rejected too, so a broken input never turns into `NaN` in the query string.\n- Sub-second precision is **lost**. Two instants inside the same second collapse to the same parameter value, which matters for cursor style pagination; use [`-value-to-ms-timestamp`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-ms-timestamp) when you need milliseconds.\n- Pre-1970 dates serialize as negative integers. Some backends parse them into unsigned types and fail; verify before using this strategy for historical data.\n- The value is timezone agnostic by design. A parameter meant to be a **local calendar day** (a birthday, an invoice date) should not be a Unix timestamp, because the receiving side has no way to know which day you meant. Use [`-value-to-date-fns`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-date-fns) with `yyyy-MM-dd` for that.\n- Beyond `2038-01-19T03:14:07Z` the value exceeds a signed 32-bit integer. JavaScript is fine with it, older backends are not.\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-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":"Unix second timestamp output strategy for HttpParamsProcessor date values.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","unix-timestamp","epoch","date"]}