Skip to content

Commit 69b896e

Browse files
committed
Feat: Add consolidated timezone imports and IANA timezone name string support
Add two new ways to use timezones: 1. Consolidated imports: Import multiple timezones from a single module import { Tokyo, New_York } from 'date-and-time/timezone'; 2. IANA timezone name strings: Use timezone names directly in format() format(date, 'YYYY-MM-DD HH:mm', { timeZone: 'Asia/Tokyo' }); The tools/timezone.ts script now generates both individual timezone files and an integrated timezone.ts file for consolidated imports. Note: The parse() function does not support IANA name strings, only TimeZone objects and the "UTC" string.
1 parent c3fe151 commit 69b896e

File tree

3 files changed

+2097
-33
lines changed

3 files changed

+2097
-33
lines changed

package.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "date-and-time",
3-
"version": "4.1.2",
3+
"version": "4.2.0",
44
"description": "The simplest, most intuitive date and time library",
55
"keywords": [
66
"date",
@@ -24,6 +24,11 @@
2424
"import": "./dist/plugin.js",
2525
"require": "./dist/plugin.cjs"
2626
},
27+
"./timezone": {
28+
"types": "./dist/timezone.d.ts",
29+
"import": "./dist/timezone.js",
30+
"require": "./dist/timezone.cjs"
31+
},
2732
"./locales/*": {
2833
"types": "./dist/locales/*.d.ts",
2934
"import": "./dist/locales/*.js",
@@ -63,6 +68,7 @@
6368
"test": "vitest run",
6469
"test:coverage": "vitest run --coverage",
6570
"timezone": "tsx tools/timezone.ts",
71+
"ts": "tsc --noEmit",
6672
"zonename": "tsx tools/zonename.ts"
6773
},
6874
"author": "KNOWLEDGECODE",
@@ -81,22 +87,21 @@
8187
"type": "module",
8288
"sideEffects": false,
8389
"devDependencies": {
84-
"@eslint/js": "^9.39.2",
8590
"@rollup/plugin-alias": "^6.0.0",
8691
"@rollup/plugin-terser": "^0.4.4",
87-
"@stylistic/eslint-plugin": "^5.6.1",
88-
"@types/node": "^25.0.2",
89-
"@vitest/coverage-v8": "^4.0.15",
92+
"@stylistic/eslint-plugin": "^5.7.0",
93+
"@types/node": "^25.0.9",
94+
"@vitest/coverage-v8": "^4.0.17",
9095
"eslint": "^9.39.2",
9196
"glob": "^13.0.0",
92-
"prettier": "^3.7.4",
93-
"rollup": "^4.53.3",
97+
"prettier": "^3.8.0",
98+
"rollup": "^4.55.1",
9499
"rollup-plugin-dts": "^6.3.0",
95100
"rollup-plugin-esbuild": "^6.2.1",
96101
"tsx": "^4.21.0",
97-
"typescript-eslint": "^8.49.0",
102+
"typescript-eslint": "^8.53.0",
98103
"vitepress": "^1.6.4",
99-
"vitest": "^4.0.15"
104+
"vitest": "^4.0.17"
100105
},
101106
"overrides": {
102107
"esbuild": "^0.25.0"

rollup.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const ts = () => {
2727
return [
2828
config('src/index.ts', 'dist'),
2929
config('src/plugin.ts', 'dist'),
30+
config('src/timezone.ts', 'dist'),
3031
config(Object.fromEntries(globSync('src/numerals/**/*.ts').map(input => [replacePath(input), input])), 'dist'),
3132
globSync('src/locales/**/*.ts').map(input => config(input, outputDir(input))),
3233
globSync('src/plugins/**/*.ts').map(input => config(input, outputDir(input))),
@@ -48,6 +49,7 @@ const types = () => {
4849
return [
4950
config('src/index.ts', 'dist'),
5051
config('src/plugin.ts', 'dist'),
52+
config('src/timezone.ts', 'dist'),
5153
config(Object.fromEntries(globSync('src/numerals/**/*.ts').map(input => [replacePath(input), input])), 'dist'),
5254
globSync('src/locales/**/*.ts').map(input => config(input, outputDir(input))),
5355
globSync('src/plugins/**/*.ts').map(input => config(input, outputDir(input))),

0 commit comments

Comments
 (0)