{"_id":"tz-local-date","_rev":"2-1eaf0fe869a4e5f6945661e665c04836","name":"tz-local-date","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"tz-local-date","version":"1.0.0","keywords":["date","timezone","format","comparison","calculation","manipulation","localization"],"author":{"name":"Dexter Tan","email":"dev@dextertanyj.com"},"license":"MIT","_id":"tz-local-date@1.0.0","maintainers":[{"name":"dextertanyj","email":"dev@dextertanyj.com"}],"homepage":"https://github.com/dextertanyj/tz-local-date","bugs":{"url":"https://github.com/dextertanyj/tz-local-date/issues"},"dist":{"shasum":"6046f9b760ee509704c04bd6a93f8faace87049a","tarball":"https://registry.npmjs.org/tz-local-date/-/tz-local-date-1.0.0.tgz","fileCount":17,"integrity":"sha512-2smfm6hf7zYSdhFP5j4DWoydmIceMyNCpJKVOMSLPCZM0vdry/UUUVh14PgBNDC4w0aNgw+XqEOPO/P7A4iQDA==","signatures":[{"sig":"MEYCIQCXH+spyaB0WpiSVY2EQw2eYJ5SEHcsHPS4ZkSdxnxjDgIhAKr9vsUqU7TkoiwidS6bsC9pqiJD5kLrKbvWeyObqvYO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37063},"main":"lib/cjs/index.js","type":"module","types":"lib/types/index.d.ts","exports":{".":{"types":"./lib/types/index.js","import":"./lib/esm/index.js","require":"./lib/cjs/index.js"},"./package.json":"./package.json"},"gitHead":"acc370344bbe88183433ac4548c4989e5bbf9cd6","scripts":{"lint":"eslint --ext ts,js .","test":"vitest --run","build":"npm run build:esm && npm run build:cjs && npm run build:types","clean":"git clean -xdf node_modules lib","prepack":"npm run build","version":"auto-changelog -p && git add CHANGELOG.md","lint:fix":"eslint --fix --ext ts,js .","benchmark":"tsx tests/benchmark.ts","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:types":"tsc -p tsconfig.types.json","test:coverage":"vitest --run --coverage"},"_npmUser":{"name":"dextertanyj","email":"dev@dextertanyj.com"},"repository":{"url":"git+https://github.com/dextertanyj/tz-local-date.git","type":"git"},"_npmVersion":"9.8.1","description":"Fast timezone-aware date comparsion and manipulation","directories":{},"_nodeVersion":"18.18.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.1.1","vite":"^4.5.0","dayjs":"^1.11.10","eslint":"^8.47.0","vitest":"^0.34.6","prettier":"^3.0.2","tinybench":"^2.5.1","typescript":"^5.1.6","auto-changelog":"^2.4.0","@vitest/coverage-v8":"^0.34.6","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","@typescript-eslint/parser":"^6.4.0","@typescript-eslint/eslint-plugin":"^6.4.0","eslint-plugin-simple-import-sort":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/tz-local-date_1.0.0_1700399609360_0.356716317348323","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"tz-local-date","version":"1.0.1","keywords":["date","timezone","format","comparison","calculation","manipulation","localization"],"author":{"name":"Dexter Tan","email":"dev@dextertanyj.com"},"license":"MIT","_id":"tz-local-date@1.0.1","maintainers":[{"name":"dextertanyj","email":"dev@dextertanyj.com"}],"homepage":"https://github.com/dextertanyj/tz-local-date","bugs":{"url":"https://github.com/dextertanyj/tz-local-date/issues"},"dist":{"shasum":"1db5fa35ecfa713ca3017aa92299b86e553a9161","tarball":"https://registry.npmjs.org/tz-local-date/-/tz-local-date-1.0.1.tgz","fileCount":13,"integrity":"sha512-HkCOah8OVNqtzvocko8I8jlItdFZtwOPQFXwdXwWurzhTpCMQzt+ri4rHEPRgFg+aGeJ2H/Jk+nuDKf67nYOaA==","signatures":[{"sig":"MEYCIQDJ4PRYHOdeWFrLwQPa8BJbuE3INMR7VeeBx/xg0gsGmwIhANL+rQSpKcLDM3OaYtQPq/U4OMKFzB5VtCf0J18vP5QZ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":39423},"main":"lib/cjs/index.cjs","types":"lib/types/index.d.ts","module":"lib/esm/index.mjs","exports":{".":{"types":"./lib/types/index.d.ts","import":"./lib/esm/index.mjs","require":"./lib/cjs/index.cjs"},"./package.json":"./package.json"},"gitHead":"327455790a770f6398e35e1edc0b5e5be53328eb","scripts":{"lint":"eslint --ext ts,js .","test":"vitest --run","build":"npm run build:esm && npm run build:cjs && npm run build:types","clean":"git clean -xdf node_modules lib","prepack":"npm run build","version":"auto-changelog -p && git add CHANGELOG.md","lint:fix":"eslint --fix --ext ts,js .","benchmark":"tsx tests/benchmark.ts","build:cjs":"esbuild src/index.ts --bundle --outdir=lib/cjs --allow-overwrite --format=cjs --minify --sourcemap --out-extension:.js=.cjs","build:esm":"esbuild src/index.ts --bundle --outdir=lib/esm --allow-overwrite --format=esm --minify --sourcemap --out-extension:.js=.mjs","build:types":"tsc -p tsconfig.types.json","test:coverage":"vitest --run --coverage"},"_npmUser":{"name":"dextertanyj","email":"dev@dextertanyj.com"},"repository":{"url":"git+https://github.com/dextertanyj/tz-local-date.git","type":"git"},"_npmVersion":"10.2.4","description":"Fast timezone-aware date comparsion and manipulation","directories":{},"_nodeVersion":"20.11.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.1.1","vite":"^4.5.0","dayjs":"^1.11.10","eslint":"^8.47.0","vitest":"^0.34.6","esbuild":"^0.20.0","prettier":"^3.0.2","tinybench":"^2.5.1","typescript":"^5.1.6","auto-changelog":"^2.4.0","@vitest/coverage-v8":"^0.34.6","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","@typescript-eslint/parser":"^6.4.0","@typescript-eslint/eslint-plugin":"^6.4.0","eslint-plugin-simple-import-sort":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/tz-local-date_1.0.1_1707275504790_0.20011274589375505","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"tz-local-date","version":"1.0.2","description":"Fast timezone-aware date comparsion and manipulation","license":"MIT","main":"lib/cjs/index.cjs","module":"lib/esm/index.mjs","types":"lib/types/index.d.ts","homepage":"https://github.com/dextertanyj/tz-local-date","author":{"name":"Dexter Tan","email":"dev@dextertanyj.com"},"repository":{"type":"git","url":"git+https://github.com/dextertanyj/tz-local-date.git"},"exports":{".":{"import":"./lib/esm/index.mjs","require":"./lib/cjs/index.cjs","types":"./lib/types/index.d.ts"},"./package.json":"./package.json"},"keywords":["date","timezone","format","comparison","calculation","manipulation","localization"],"scripts":{"prepack":"npm run build","build":"npm run build:esm && npm run build:cjs && npm run build:types","build:esm":"esbuild src/index.ts --bundle --outdir=lib/esm --allow-overwrite --format=esm --minify --sourcemap --out-extension:.js=.mjs","build:cjs":"esbuild src/index.ts --bundle --outdir=lib/cjs --allow-overwrite --format=cjs --minify --sourcemap --out-extension:.js=.cjs","build:types":"tsc -p tsconfig.types.json","lint":"eslint --ext ts,js .","lint:fix":"eslint --fix --ext ts,js .","clean":"git clean -xdf node_modules lib","test":"vitest --run","test:coverage":"vitest --run --coverage","benchmark":"tsx tests/benchmark.ts","version":"auto-changelog -p && git add CHANGELOG.md"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^6.4.0","@typescript-eslint/parser":"^6.4.0","@vitest/coverage-v8":"^0.34.6","auto-changelog":"^2.4.0","dayjs":"^1.11.10","esbuild":"^0.20.0","eslint":"^8.47.0","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","eslint-plugin-simple-import-sort":"^10.0.0","prettier":"^3.0.2","tinybench":"^2.5.1","tsx":"^4.1.1","typescript":"^5.1.6","vite":"^4.5.0","vitest":"^0.34.6"},"_id":"tz-local-date@1.0.2","gitHead":"82cc68ebf7ec1b47943b424b5392a68010c6abcd","bugs":{"url":"https://github.com/dextertanyj/tz-local-date/issues"},"_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-0eh60eMD0ZvdaFGbkj6Vz2aPUE5rIAdGAtH6bihLGbg4JKebS9gfUML41daxXwvak/ss87vzgceOJIFevsP7EA==","shasum":"30adabef29bb47619a86e1249cca909d2b71089f","tarball":"https://registry.npmjs.org/tz-local-date/-/tz-local-date-1.0.2.tgz","fileCount":13,"unpackedSize":45559,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDrg9drHP/ucIF3yW4RmahDfFoK4BKwkFzOiOPwIYtH5AiEAykeG8YpborsDOZRhlZsubiphCgqDHRk5VdFzOm9FFWY="}]},"_npmUser":{"name":"dextertanyj","email":"dev@dextertanyj.com"},"directories":{},"maintainers":[{"name":"dextertanyj","email":"dev@dextertanyj.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tz-local-date_1.0.2_1723981088164_0.4242412295347835"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-19T13:13:29.359Z","modified":"2024-08-18T11:38:08.565Z","1.0.0":"2023-11-19T13:13:29.530Z","1.0.1":"2024-02-07T03:11:44.941Z","1.0.2":"2024-08-18T11:38:08.381Z"},"bugs":{"url":"https://github.com/dextertanyj/tz-local-date/issues"},"author":{"name":"Dexter Tan","email":"dev@dextertanyj.com"},"license":"MIT","homepage":"https://github.com/dextertanyj/tz-local-date","keywords":["date","timezone","format","comparison","calculation","manipulation","localization"],"repository":{"type":"git","url":"git+https://github.com/dextertanyj/tz-local-date.git"},"description":"Fast timezone-aware date comparsion and manipulation","maintainers":[{"name":"dextertanyj","email":"dev@dextertanyj.com"}],"readme":"# Timezone Local Date\n\n[![CI](https://github.com/dextertanyj/tz-local-date/actions/workflows/ci.yml/badge.svg)](https://github.com/dextertanyj/tz-local-date/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/dextertanyj/tz-local-date/badge.svg?branch=master)](https://coveralls.io/github/dextertanyj/tz-local-date?branch=master)\n\nFast timezone-aware date comparsion and manipulation.\n\n## Features\n\n- ⚡️ Fast date calculations using native `Date` objects\n- 🌏 Timezone-aware with support for daylight saving time\n- 🪶 Lightweight with no dependencies\n\n## Quickstart\n\n**1. Install `tz-local-date`.**\n\n```shell\nnpm install tz-local-date\n```\n\n**2. Initialize an instance with the desired timezone.**\n\n```ts\nimport { LocalDate } from \"tz-local-date\";\n\nconst ld = new LocalDate(\"UTC\");\n```\n\n**3. Start comparing and manipulating dates.**\n\n```ts\nconst now = new Date();\n\nconst startOfToday = ld.startOfDay(now);\nconst tomorrow = ld.startOfNextDay(now);\n\nld.isAfter(tomorrow, startOfToday); // returns true\n```\n\n## API Reference\n\n### Constructor\n\n**`LocalDate`** \\\n`LocalDate(timezone: string, reference?: Date | number)`\n\nConstructs a new `LocalDate` instance configured with the given timezone.\nAll calculations and comparisons using the constructed `LocalDate` instance will normalize given inputs to the configured timezone.\\\nThe given timezone must be a valid IANA TZ identifier.\n\nThe optional `reference` parameter determines the date which is used to calculate the offset of the given timezone from UTC.\nThis parameter is useful for timezones with daylight saving time, or has changed since 1 Jan 1970.\n_Defaults to UNIX epoch._\n\n### Date Manipulation\n\n**`LocalDate::startOfDay`** \\\n`startOfDay(date: Date | number): Date`\n\nReturns a `Date` representing the start of the day (i.e. 12 midnight) of the given date.\n\n```ts\nconst ld = new LocalDate(\"Asia/Singapore\");\n\nld.startOfDay(new Date(\"2023-01-01T12:34:56+08:00\")); // Returns new Date('2023-01-01T00:00:00.000+08:00')\n\n// The date returned is indepdenent of the timezone used to contruct the given Date object.\nld.staryOfDay(new Date(\"2023-01-01T04:03:02+00:00\")); // Returns new Date('2023-01-01T00:00:00.000+08:00')\n```\n\n**`LocalDate::startOfNextDay`** \\\n`startOfNextDay(date: Date | number): Date`\n\nReturns a `Date` representing the start of the next day of the given date.\n\n```ts\nconst ld = new LocalDate(\"Asia/Singapore\");\n\nld.startOfNextDay(new Date(\"2023-01-01T12:34:56+08:00\")); // Returns new Date('2023-01-02T00:00:00.000+08:00')\n```\n\n**`LocalDate::startOfPreviousDay`** \\\n`startOfPreviousDay(date: Date | number): Date`\n\nReturns a `Date` representing the start of the previous day of the given date.\n\n```ts\nconst ld = new LocalDate(\"Asia/Singapore\");\n\nld.startOfNextDay(new Date(\"2023-01-01T12:34:56+08:00\")); // Returns new Date('2022-12-31T00:00:00.000+08:00')\n```\n\n**`LocalDate::endOfDay`** \\\n`endOfDay(date: Date | number): Date`\n\nReturns a `Date` representing the end of the day (i.e. 1 millisecond before 12 midnight) of the given date.\n\n```ts\nconst ld = new LocalDate(\"Asia/Singapore\");\n\nld.endOfDay(new Date(\"2023-01-01T12:34:56+08:00\")); // Returns new Date('2023-01-01T23:59:59.999+08:00')\n```\n\n### Date Comparison\n\n**`LocalDate::isSame`** \\\n`isSame(lhs: Date | number, rhs: Date | number): boolean`\n\nReturns `true` if `lhs` has the same date as `rhs` in the configured timezone, `false` otherwise.\n\n**`LocalDate::isSameOrBefore`** \\\n`isSameOrBefore(lhs: Date | number, rhs: Date | number): boolean`\n\nReturns `true` if `lhs` has the same date as or is before `rhs` in the configured timezone, `false` otherwise.\n\n**`LocalDate::isSameOrAfter`** \\\n`isSameOrAfter(lhs: Date | number, rhs: Date | number): boolean`\n\nReturns `true` if `lhs` has the same date as or is after `rhs` in the configured timezone, `false` otherwise.\n\n**`LocalDate::isBefore`** \\\n`isBefore(lhs: Date | number, rhs: Date | number): boolean`\n\nReturns `true` if the date `lhs` is strictly before the date of `rhs` in the configured timezone, `false` otherwise. \\\nIgnores the time components of `lhs` and `rhs`.\n\n**`LocalDate::isAfter`** \\\n`isAfter(lhs: Date | number, rhs: Date | number): boolean`\n\nReturns `true` if the date `lhs` is strictly after the date of `rhs` in the configured timezone, `false` otherwise. \\\nIgnores the time components of `lhs` and `rhs`.\n\n### Date Parsing\n\n**`LocalDate::format`** \\\n`format(date: Date | number, format?: string): string`\n\nReturns the given date as a string formatted according to the given string of tokens. \\\n_Defaults to `YYYY-MM-DD`._\n\n> **Supported Tokens** \\\n> `YYYY`: Year, padded to four digits. \\\n> `YY`: Year, truncated to two digits. \\\n> `M`: Month, starting from 1. \\\n> `MM`: Month, starting from 1, padded to two digits. \\\n> `D`: Day of month, starting from 1. \\\n> `DD`: Day of month, starting from 1, padded to two digits.\n\n**`LocalDate::getComponents`** \\\n`getComponents(date: Date | number): { year: number; month: number; day: number }`\n\nReturns the year, month, and day of month of the given date, localized to the configured timezone.\n\n**`LocalDate::getDay`** \\\n`getDay(date: Date | number): \"Monday\" | \"Tuesday\" | \"Wednesday\" | \"Thursday\" | \"Friday\" | \"Saturday\" | \"Sunday\"`\n\nReturns the day of the week of the given date, localized to the configured timezone.\n\n**`LocalDate::getMillisecondsFromStartOfDay`** \\\n`getMillisecondsFromStartOfDay(date: Date | number): number`\n\nReturns the number of milliseconds the given date is from the start of the day (i.e. 12 midnight), localized to the configured timezone.\n\n### Daylight Saving Time Adjustments\n\n**`LocalDate::at`** \\\n`at(reference: Date | number): LocalDate`\n\nReturns a new `LocalDate` instance with its `reference` set to the given date.\n","readmeFilename":"README.md"}