Skip to content

Commit e793ed9

Browse files
committed
feat!: drop Node.js 18 and 20 support, require Node.js 22+
BREAKING CHANGE: Minimum Node.js version is now 22. Users on Node.js 18-21 must upgrade. - Update all dependencies to latest versions - Fix Jest 30 breaking change (toThrowError → toThrow) - Add readonly types to constant arrays - Update CI matrix to test Node.js 22 and 24
1 parent f4db454 commit e793ed9

12 files changed

Lines changed: 2825 additions & 3021 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
node-version: [18, 20, 22]
17+
node-version: [22, 24]
1818
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
1919

2020
steps:

.github/workflows/release-please.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Setup node
2929
uses: actions/setup-node@v4
3030
with:
31-
node-version: 22
31+
node-version: 24
3232
registry-url: 'https://registry.npmjs.org'
3333
if: ${{ steps.release.outputs.release_created }}
3434

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{".":"1.5.0"}
1+
{".":"2.0.0"}

package-lock.json

Lines changed: 2735 additions & 2956 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nepali-datetime",
3-
"version": "1.5.0",
3+
"version": "2.0.0",
44
"description": "A Node project designed to support native JavaScript-like features for Nepali dates. It includes features such as 'NepaliDate' for Nepali date support and 'dateConverter' for date conversions.",
55
"exports": {
66
".": {
@@ -58,21 +58,21 @@
5858
"author": "OpenSource Nepal",
5959
"license": "GPL-3.0",
6060
"devDependencies": {
61-
"@commitlint/cli": "^19.6.1",
62-
"@commitlint/config-conventional": "^19.6.0",
63-
"@types/jest": "^29.5.4",
64-
"@types/node": "^22.10.2",
61+
"@commitlint/cli": "^20.4.0",
62+
"@commitlint/config-conventional": "^20.4.0",
63+
"@types/jest": "^30.0.0",
64+
"@types/node": "^25.1.0",
6565
"husky": "^9.1.7",
66-
"jest": "^29.7.0",
67-
"lint-staged": "^15.2.11",
68-
"prettier": "^3.4.2",
69-
"ts-jest": "^29.2.5",
66+
"jest": "^30.2.0",
67+
"lint-staged": "^16.2.7",
68+
"prettier": "^3.8.1",
69+
"ts-jest": "^29.4.6",
7070
"ts-node": "^10.9.2",
7171
"tslib": "^2.8.1",
72-
"typescript": "^5.7.2",
73-
"unbuild": "^3.0.1"
72+
"typescript": "^5.9.3",
73+
"unbuild": "^3.6.1"
7474
},
7575
"engines": {
76-
"node": ">=18"
76+
"node": ">=22"
7777
}
7878
}

src/constants.ts

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const OLD_UTC_OFFSET_IN_MS = 19800000 // 5 hours 40 minutes in ms
1111
export const TIMEZONE_TRANSITION_TIMESTAMP = 504901800000
1212
export const TIMEZONE_TRANSITION_DATE_REFERENCE = new Date(1986, 0, 1, 0, 15)
1313

14-
export const NEPALI_MONTHS_EN = [
14+
export const NEPALI_MONTHS_EN: readonly string[] = [
1515
'Baisakh',
1616
'Jestha',
1717
'Asar',
@@ -26,7 +26,7 @@ export const NEPALI_MONTHS_EN = [
2626
'Chaitra',
2727
]
2828

29-
export const NEPALI_MONTHS_SHORT_EN = [
29+
export const NEPALI_MONTHS_SHORT_EN: readonly string[] = [
3030
'Bai',
3131
'Jes',
3232
'Asa',
@@ -41,7 +41,7 @@ export const NEPALI_MONTHS_SHORT_EN = [
4141
'Cha',
4242
]
4343

44-
export const NEPALI_MONTHS_NE = [
44+
export const NEPALI_MONTHS_NE: readonly string[] = [
4545
'बैशाख',
4646
'जेठ',
4747
'असार',
@@ -56,7 +56,7 @@ export const NEPALI_MONTHS_NE = [
5656
'चैत्र',
5757
]
5858

59-
export const NEPALI_MONTHS_SHORT_NE = [
59+
export const NEPALI_MONTHS_SHORT_NE: readonly string[] = [
6060
'बै',
6161
'जे',
6262
'अ',
@@ -71,7 +71,7 @@ export const NEPALI_MONTHS_SHORT_NE = [
7171
'चै',
7272
]
7373

74-
export const ENGLISH_MONTHS_EN = [
74+
export const ENGLISH_MONTHS_EN: readonly string[] = [
7575
'January',
7676
'February',
7777
'March',
@@ -86,7 +86,7 @@ export const ENGLISH_MONTHS_EN = [
8686
'December',
8787
]
8888

89-
export const ENGLISH_MONTHS_SHORT_EN = [
89+
export const ENGLISH_MONTHS_SHORT_EN: readonly string[] = [
9090
'Jan',
9191
'Feb',
9292
'Mar',
@@ -101,7 +101,7 @@ export const ENGLISH_MONTHS_SHORT_EN = [
101101
'Dec',
102102
]
103103

104-
export const ENGLISH_MONTHS_NE = [
104+
export const ENGLISH_MONTHS_NE: readonly string[] = [
105105
'जनवरी',
106106
'फेब्रुअरी',
107107
'मार्च',
@@ -116,7 +116,7 @@ export const ENGLISH_MONTHS_NE = [
116116
'डिसेम्बर',
117117
]
118118

119-
export const ENGLISH_MONTHS_SHORT_NE = [
119+
export const ENGLISH_MONTHS_SHORT_NE: readonly string[] = [
120120
'जन',
121121
'फेब',
122122
'मार',
@@ -131,11 +131,30 @@ export const ENGLISH_MONTHS_SHORT_NE = [
131131
'डिसे',
132132
]
133133

134-
export const NUM_NE = ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९']
134+
export const NUM_NE: readonly string[] = [
135+
'०',
136+
'१',
137+
'२',
138+
'३',
139+
'४',
140+
'५',
141+
'६',
142+
'७',
143+
'८',
144+
'९',
145+
]
135146

136-
export const WEEKDAYS_SHORT_EN = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
147+
export const WEEKDAYS_SHORT_EN: readonly string[] = [
148+
'Sun',
149+
'Mon',
150+
'Tue',
151+
'Wed',
152+
'Thu',
153+
'Fri',
154+
'Sat',
155+
]
137156

138-
export const WEEKDAYS_LONG_EN = [
157+
export const WEEKDAYS_LONG_EN: readonly string[] = [
139158
'Sunday',
140159
'Monday',
141160
'Tuesday',
@@ -145,9 +164,17 @@ export const WEEKDAYS_LONG_EN = [
145164
'Saturday',
146165
]
147166

148-
export const WEEKDAYS_SHORT_NE = ['आइत', 'सोम', 'मंगल', 'बुध', 'बिहि', 'शुक्र', 'शनि']
167+
export const WEEKDAYS_SHORT_NE: readonly string[] = [
168+
'आइत',
169+
'सोम',
170+
'मंगल',
171+
'बुध',
172+
'बिहि',
173+
'शुक्र',
174+
'शनि',
175+
]
149176

150-
export const WEEKDAYS_LONG_NE = [
177+
export const WEEKDAYS_LONG_NE: readonly string[] = [
151178
'आइतबार',
152179
'सोमबार',
153180
'मंगलबार',

src/dateConverter/constants.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
// Reference date for conversion is 2000/01/01 BS and 1943/4/14 AD
22
export const NP_INITIAL_YEAR = 2000
3-
export const REFERENCE_EN_DATE: [number, number, number] = [1943, 4, 14]
3+
export const REFERENCE_EN_DATE: readonly [number, number, number] = [1943, 4, 14]
44

55
// English month constant data (will never change)
6-
export const EN_MONTHS: number[] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
7-
export const EN_LEAP_YEAR_MONTHS: number[] = [
6+
export const EN_MONTHS: readonly number[] = [
7+
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
8+
]
9+
export const EN_LEAP_YEAR_MONTHS: readonly number[] = [
810
31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
911
] // Leap year months (Just 29 on Feb)
1012

1113
// Nepali months data
12-
export const NP_MONTHS_DATA: Array<[number[], number]> = [
14+
export const NP_MONTHS_DATA: ReadonlyArray<readonly [readonly number[], number]> = [
1315
[[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], // 2000 BS - 1943/1944 AD
1416
[[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], // 2001 BS
1517
[[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365],

src/dateConverter/dateConverter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const _isLeapYear = (year: number): boolean => {
102102
* @param year - The year for which to retrieve the months.
103103
* @returns An array containing the number of days in each month of the year.
104104
*/
105-
const _getEnMonths = (year: number): number[] => {
105+
const _getEnMonths = (year: number): readonly number[] => {
106106
return _isLeapYear(year) ? EN_LEAP_YEAR_MONTHS : EN_MONTHS
107107
}
108108

@@ -308,7 +308,7 @@ const nepaliToEnglish = (
308308

309309
// MONTH
310310
// Incrementing month until the difference remains less than next english month (mostly 31)
311-
const month_days: number[] = _getEnMonths(en_year)
311+
const month_days: readonly number[] = _getEnMonths(en_year)
312312
let i = 0
313313
while (difference >= month_days[i]) {
314314
difference -= month_days[i]

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const parseFormatTokens = (format: string): string[] => {
4141
*
4242
* @param toConvert - An array of string containing all the required regex values
4343
*/
44-
export const seqToRE = (toConvert: Array<string>): RegExp => {
44+
export const seqToRE = (toConvert: readonly string[]): RegExp => {
4545
// returns /(?:)/ regex for empty array
4646
if (toConvert.length === 0) {
4747
return new RegExp('')

tests/NepaliDate.test.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ describe('NepaliDate with Time feature initialization', () => {
355355

356356
expect(() => {
357357
const _ = new NepaliDate(year, month, day, hour, minute, second, ms)
358-
}).toThrowError(new ValidationError('Hour should be in the range 0-23'))
358+
}).toThrow(new ValidationError('Hour should be in the range 0-23'))
359359
})
360360

361361
it('should throw a ValidationError for invalid negative hour', () => {
@@ -367,7 +367,7 @@ describe('NepaliDate with Time feature initialization', () => {
367367

368368
expect(() => {
369369
const _ = new NepaliDate(year, month, day, hour, minute, second, ms)
370-
}).toThrowError(new ValidationError('Hour should be in the range 0-23'))
370+
}).toThrow(new ValidationError('Hour should be in the range 0-23'))
371371
})
372372

373373
it('should throw a ValidationError for invalid minute', () => {
@@ -379,7 +379,7 @@ describe('NepaliDate with Time feature initialization', () => {
379379

380380
expect(() => {
381381
const _ = new NepaliDate(year, month, day, hour, minute, second, ms)
382-
}).toThrowError(new ValidationError('Minute should be in the range 0-59'))
382+
}).toThrow(new ValidationError('Minute should be in the range 0-59'))
383383
})
384384

385385
it('should throw a ValidationError for invalid negative minute', () => {
@@ -391,7 +391,7 @@ describe('NepaliDate with Time feature initialization', () => {
391391

392392
expect(() => {
393393
const _ = new NepaliDate(year, month, day, hour, minute, second, ms)
394-
}).toThrowError(new ValidationError('Minute should be in the range 0-59'))
394+
}).toThrow(new ValidationError('Minute should be in the range 0-59'))
395395
})
396396

397397
it('should throw a ValidationError for invalid second', () => {
@@ -403,7 +403,7 @@ describe('NepaliDate with Time feature initialization', () => {
403403

404404
expect(() => {
405405
const _ = new NepaliDate(year, month, day, hour, minute, second, ms)
406-
}).toThrowError(new ValidationError('Second should be in the range 0-59'))
406+
}).toThrow(new ValidationError('Second should be in the range 0-59'))
407407
})
408408

409409
it('should throw a ValidationError for invalid negative second', () => {
@@ -415,7 +415,7 @@ describe('NepaliDate with Time feature initialization', () => {
415415

416416
expect(() => {
417417
const _ = new NepaliDate(year, month, day, hour, minute, second, ms)
418-
}).toThrowError(new ValidationError('Second should be in the range 0-59'))
418+
}).toThrow(new ValidationError('Second should be in the range 0-59'))
419419
})
420420

421421
it('should throw a ValidationError for invalid millisecond', () => {
@@ -427,7 +427,7 @@ describe('NepaliDate with Time feature initialization', () => {
427427

428428
expect(() => {
429429
const _ = new NepaliDate(year, month, day, hour, minute, second, ms)
430-
}).toThrowError(new ValidationError('Millisecond should be in the range 0-999'))
430+
}).toThrow(new ValidationError('Millisecond should be in the range 0-999'))
431431
})
432432

433433
it('should throw a ValidationError for invalid negative millisecond', () => {
@@ -439,7 +439,7 @@ describe('NepaliDate with Time feature initialization', () => {
439439

440440
expect(() => {
441441
const _ = new NepaliDate(year, month, day, hour, minute, second, ms)
442-
}).toThrowError(new ValidationError('Millisecond should be in the range 0-999'))
442+
}).toThrow(new ValidationError('Millisecond should be in the range 0-999'))
443443
})
444444

445445
// timezone support
@@ -680,7 +680,7 @@ describe('NepaliDate with Time feature: set methods', () => {
680680
const invalidHour = 24
681681
expect(() => {
682682
nepaliDate.setHours(invalidHour)
683-
}).toThrowError(new ValidationError('Hour should be in the range 0-23'))
683+
}).toThrow(new ValidationError('Hour should be in the range 0-23'))
684684
})
685685
})
686686

@@ -696,7 +696,7 @@ describe('NepaliDate with Time feature: set methods', () => {
696696
const invalidMinute = 60
697697
expect(() => {
698698
nepaliDate.setMinutes(invalidMinute)
699-
}).toThrowError(new ValidationError('Minute should be in the range 0-59'))
699+
}).toThrow(new ValidationError('Minute should be in the range 0-59'))
700700
})
701701
})
702702

@@ -712,7 +712,7 @@ describe('NepaliDate with Time feature: set methods', () => {
712712
const invalidSecond = 60
713713
expect(() => {
714714
nepaliDate.setSeconds(invalidSecond)
715-
}).toThrowError(new ValidationError('Second should be in the range 0-59'))
715+
}).toThrow(new ValidationError('Second should be in the range 0-59'))
716716
})
717717
})
718718

@@ -728,9 +728,7 @@ describe('NepaliDate with Time feature: set methods', () => {
728728
const invalidMillisecond = 1000
729729
expect(() => {
730730
nepaliDate.setMilliseconds(invalidMillisecond)
731-
}).toThrowError(
732-
new ValidationError('Millisecond should be in the range 0-999')
733-
)
731+
}).toThrow(new ValidationError('Millisecond should be in the range 0-999'))
734732
})
735733
})
736734

0 commit comments

Comments
 (0)