nhb-toolbox 3.9.70 → 3.9.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/date/Chronos.d.ts +32 -9
- package/dist/date/Chronos.d.ts.map +1 -1
- package/dist/date/Chronos.js +53 -27
- package/package.json +4 -2
package/dist/date/Chronos.d.ts
CHANGED
|
@@ -242,20 +242,23 @@ export declare class Chronos {
|
|
|
242
242
|
* @instance Checks if another date is the same as this one in a specific unit.
|
|
243
243
|
* @param other The other date to compare.
|
|
244
244
|
* @param unit The unit to compare.
|
|
245
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
245
246
|
*/
|
|
246
|
-
isSame(other: ChronosInput, unit: TimeUnit): boolean;
|
|
247
|
+
isSame(other: ChronosInput, unit: TimeUnit, weekStartsOn?: number): boolean;
|
|
247
248
|
/**
|
|
248
249
|
* @instance Checks if this date is before another date in a specific unit.
|
|
249
250
|
* @param other The other date to compare.
|
|
251
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
250
252
|
* @param unit The unit to compare.
|
|
251
253
|
*/
|
|
252
|
-
isBefore(other: ChronosInput, unit: TimeUnit): boolean;
|
|
254
|
+
isBefore(other: ChronosInput, unit: TimeUnit, weekStartsOn?: number): boolean;
|
|
253
255
|
/**
|
|
254
256
|
* @instance Checks if this date is after another date in a specific unit.
|
|
255
257
|
* @param other The other date to compare.
|
|
256
258
|
* @param unit The unit to compare.
|
|
259
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
257
260
|
*/
|
|
258
|
-
isAfter(other: ChronosInput, unit: TimeUnit): boolean;
|
|
261
|
+
isAfter(other: ChronosInput, unit: TimeUnit, weekStartsOn?: number): boolean;
|
|
259
262
|
/**
|
|
260
263
|
* @instance Checks if the current date is between the given start and end dates.
|
|
261
264
|
*
|
|
@@ -406,13 +409,15 @@ export declare class Chronos {
|
|
|
406
409
|
/**
|
|
407
410
|
* @instance Returns a new Chronos instance at the start of a given unit.
|
|
408
411
|
* @param unit The unit to reset (e.g., year, month, day).
|
|
412
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
409
413
|
*/
|
|
410
|
-
startOf(unit: TimeUnit): Chronos;
|
|
414
|
+
startOf(unit: TimeUnit, weekStartsOn?: number): Chronos;
|
|
411
415
|
/**
|
|
412
416
|
* @instance Returns a new Chronos instance at the end of a given unit.
|
|
413
417
|
* @param unit The unit to adjust (e.g., year, month, day).
|
|
418
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
414
419
|
*/
|
|
415
|
-
endOf(unit: TimeUnit): Chronos;
|
|
420
|
+
endOf(unit: TimeUnit, weekStartsOn?: number): Chronos;
|
|
416
421
|
/**
|
|
417
422
|
* @instance Returns a new Chronos instance with the specified unit added.
|
|
418
423
|
* @param amount The amount to add (can be negative).
|
|
@@ -458,12 +463,30 @@ export declare class Chronos {
|
|
|
458
463
|
*/
|
|
459
464
|
setWeek(week: number): Chronos;
|
|
460
465
|
/**
|
|
461
|
-
* @instance Calculates the ISO week number of the year.
|
|
462
|
-
*
|
|
466
|
+
* @instance Calculates the ISO 8601 week number of the year.
|
|
467
|
+
*
|
|
468
|
+
* ISO weeks start on Monday, and the first week of the year is the one containing January 4th.
|
|
469
|
+
*
|
|
470
|
+
* @returns Week number (1–53).
|
|
463
471
|
*/
|
|
464
472
|
getWeek(): number;
|
|
465
|
-
/**
|
|
466
|
-
|
|
473
|
+
/**
|
|
474
|
+
* @instance Calculates the week number of the year based on custom week start.
|
|
475
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
476
|
+
* @returns Week number (1-53).
|
|
477
|
+
*/
|
|
478
|
+
getWeekOfYear(weekStartsOn?: number): number;
|
|
479
|
+
/**
|
|
480
|
+
* @instance Returns the ISO week-numbering year for the current date.
|
|
481
|
+
*
|
|
482
|
+
* The ISO week-numbering year may differ from the calendar year.
|
|
483
|
+
* For example, January 1st may fall in the last ISO week of the previous year.
|
|
484
|
+
*
|
|
485
|
+
* @param weekStartsOn Optional: Defines the start day of the week (0 = Sunday, 1 = Monday).
|
|
486
|
+
* Defaults to 0 (Sunday). Use 1 for strict ISO 8601.
|
|
487
|
+
* @returns The ISO week-numbering year.
|
|
488
|
+
*/
|
|
489
|
+
getWeekYear(weekStartsOn?: number): number;
|
|
467
490
|
/** @instance Returns day of year (1 - 366) */
|
|
468
491
|
getDayOfYear(): number;
|
|
469
492
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chronos.d.ts","sourceRoot":"","sources":["../../src/date/Chronos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,OAAO,EAIN,MAAM,EAKN,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAEX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,OAAO,EACP,aAAa,EACb,aAAa,EACb,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,OAAO;;IAGnB,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAEnC;;;;;;OAMG;;IAGH;;;;;;OAMG;gBACS,KAAK,EAAE,MAAM;IAEzB;;;;;;OAMG;gBACS,KAAK,EAAE,MAAM;IAEzB;;;;;;OAMG;gBACS,KAAK,EAAE,IAAI;IAEvB;;;;;;OAMG;gBACS,KAAK,EAAE,OAAO;IAE1B;;;;;;;;;;;;OAYG;gBAEF,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,C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AE,YAAY,EAAE,GAAG,OAAO;IAM7C;;;OAGG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO;IAM7C;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO;IAgB9C;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI;IAIjD;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM;IAIpD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO;CAGvD"}
|
package/dist/date/Chronos.js
CHANGED
|
@@ -515,31 +515,34 @@ export class Chronos {
|
|
|
515
515
|
* @instance Checks if another date is the same as this one in a specific unit.
|
|
516
516
|
* @param other The other date to compare.
|
|
517
517
|
* @param unit The unit to compare.
|
|
518
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
518
519
|
*/
|
|
519
|
-
isSame(other, unit) {
|
|
520
|
+
isSame(other, unit, weekStartsOn = 0) {
|
|
520
521
|
const time = new Chronos(other);
|
|
521
|
-
return (this.startOf(unit).toDate().getTime() ===
|
|
522
|
-
time.startOf(unit).toDate().getTime());
|
|
522
|
+
return (this.startOf(unit, weekStartsOn).toDate().getTime() ===
|
|
523
|
+
time.startOf(unit, weekStartsOn).toDate().getTime());
|
|
523
524
|
}
|
|
524
525
|
/**
|
|
525
526
|
* @instance Checks if this date is before another date in a specific unit.
|
|
526
527
|
* @param other The other date to compare.
|
|
528
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
527
529
|
* @param unit The unit to compare.
|
|
528
530
|
*/
|
|
529
|
-
isBefore(other, unit) {
|
|
531
|
+
isBefore(other, unit, weekStartsOn = 0) {
|
|
530
532
|
const time = new Chronos(other);
|
|
531
|
-
return (this.startOf(unit).toDate().getTime() <
|
|
532
|
-
time.startOf(unit).toDate().getTime());
|
|
533
|
+
return (this.startOf(unit, weekStartsOn).toDate().getTime() <
|
|
534
|
+
time.startOf(unit, weekStartsOn).toDate().getTime());
|
|
533
535
|
}
|
|
534
536
|
/**
|
|
535
537
|
* @instance Checks if this date is after another date in a specific unit.
|
|
536
538
|
* @param other The other date to compare.
|
|
537
539
|
* @param unit The unit to compare.
|
|
540
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
538
541
|
*/
|
|
539
|
-
isAfter(other, unit) {
|
|
542
|
+
isAfter(other, unit, weekStartsOn = 0) {
|
|
540
543
|
const time = new Chronos(other);
|
|
541
|
-
return (this.startOf(unit).toDate().getTime() >
|
|
542
|
-
time.startOf(unit).toDate().getTime());
|
|
544
|
+
return (this.startOf(unit, weekStartsOn).toDate().getTime() >
|
|
545
|
+
time.startOf(unit, weekStartsOn).toDate().getTime());
|
|
543
546
|
}
|
|
544
547
|
/**
|
|
545
548
|
* @instance Checks if the current date is between the given start and end dates.
|
|
@@ -883,8 +886,9 @@ export class Chronos {
|
|
|
883
886
|
/**
|
|
884
887
|
* @instance Returns a new Chronos instance at the start of a given unit.
|
|
885
888
|
* @param unit The unit to reset (e.g., year, month, day).
|
|
889
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
886
890
|
*/
|
|
887
|
-
startOf(unit) {
|
|
891
|
+
startOf(unit, weekStartsOn = 0) {
|
|
888
892
|
const d = new Date(this.#date);
|
|
889
893
|
switch (unit) {
|
|
890
894
|
case 'year':
|
|
@@ -896,8 +900,8 @@ export class Chronos {
|
|
|
896
900
|
d.setHours(0, 0, 0, 0);
|
|
897
901
|
break;
|
|
898
902
|
case 'week': {
|
|
899
|
-
const day = d.getDay();
|
|
900
|
-
const diff = (day +
|
|
903
|
+
const day = d.getDay();
|
|
904
|
+
const diff = (day - weekStartsOn + 7) % 7;
|
|
901
905
|
d.setDate(d.getDate() - diff);
|
|
902
906
|
d.setHours(0, 0, 0, 0);
|
|
903
907
|
break;
|
|
@@ -922,9 +926,10 @@ export class Chronos {
|
|
|
922
926
|
/**
|
|
923
927
|
* @instance Returns a new Chronos instance at the end of a given unit.
|
|
924
928
|
* @param unit The unit to adjust (e.g., year, month, day).
|
|
929
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
925
930
|
*/
|
|
926
|
-
endOf(unit) {
|
|
927
|
-
return this.startOf(unit)
|
|
931
|
+
endOf(unit, weekStartsOn = 0) {
|
|
932
|
+
return this.startOf(unit, weekStartsOn)
|
|
928
933
|
.add(1, unit)
|
|
929
934
|
.add(-1, 'millisecond')
|
|
930
935
|
.#withOrigin('endOf');
|
|
@@ -1133,21 +1138,42 @@ export class Chronos {
|
|
|
1133
1138
|
return new Chronos(d).#withOrigin('setWeek');
|
|
1134
1139
|
}
|
|
1135
1140
|
/**
|
|
1136
|
-
* @instance Calculates the ISO week number of the year.
|
|
1137
|
-
*
|
|
1141
|
+
* @instance Calculates the ISO 8601 week number of the year.
|
|
1142
|
+
*
|
|
1143
|
+
* ISO weeks start on Monday, and the first week of the year is the one containing January 4th.
|
|
1144
|
+
*
|
|
1145
|
+
* @returns Week number (1–53).
|
|
1138
1146
|
*/
|
|
1139
1147
|
getWeek() {
|
|
1140
|
-
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
.
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1148
|
+
const target = this.startOf('week', 1).add(3, 'day'); // Thursday of current ISO week
|
|
1149
|
+
const firstThursday = new Chronos(target.year, 1, 4) // January 4
|
|
1150
|
+
.startOf('week', 1)
|
|
1151
|
+
.add(3, 'day'); // Thursday of first ISO week
|
|
1152
|
+
return target.diff(firstThursday, 'week') + 1;
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* @instance Calculates the week number of the year based on custom week start.
|
|
1156
|
+
* @param weekStartsOn Optional: Day the week starts on (0 = Sunday, 1 = Monday). Default is `0`.
|
|
1157
|
+
* @returns Week number (1-53).
|
|
1158
|
+
*/
|
|
1159
|
+
getWeekOfYear(weekStartsOn = 0) {
|
|
1160
|
+
const startOfYear = new Chronos(this.year, 1, 1);
|
|
1161
|
+
const startOfFirstWeek = startOfYear.startOf('week', weekStartsOn);
|
|
1162
|
+
const week = this.startOf('week', weekStartsOn).diff(startOfFirstWeek, 'week');
|
|
1163
|
+
return week + 1;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* @instance Returns the ISO week-numbering year for the current date.
|
|
1167
|
+
*
|
|
1168
|
+
* The ISO week-numbering year may differ from the calendar year.
|
|
1169
|
+
* For example, January 1st may fall in the last ISO week of the previous year.
|
|
1170
|
+
*
|
|
1171
|
+
* @param weekStartsOn Optional: Defines the start day of the week (0 = Sunday, 1 = Monday).
|
|
1172
|
+
* Defaults to 0 (Sunday). Use 1 for strict ISO 8601.
|
|
1173
|
+
* @returns The ISO week-numbering year.
|
|
1174
|
+
*/
|
|
1175
|
+
getWeekYear(weekStartsOn = 0) {
|
|
1176
|
+
const d = this.startOf('week', weekStartsOn).add(3, 'day'); // Thursday of current ISO week
|
|
1151
1177
|
return d.year;
|
|
1152
1178
|
}
|
|
1153
1179
|
/** @instance Returns day of year (1 - 366) */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.73",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions for everyday development needs.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git+https://github.com/nazmul-nhb/nhb-toolbox.git"
|
|
17
17
|
},
|
|
18
|
+
"homepage": "https://nhb-toolbox.vercel.app",
|
|
18
19
|
"keywords": [
|
|
19
20
|
"toolbox",
|
|
20
21
|
"utility",
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"lint": "node scripts/lint.mjs",
|
|
61
62
|
"fix": "node scripts/fix.mjs",
|
|
62
63
|
"commit": "node scripts/commit.mjs",
|
|
63
|
-
"
|
|
64
|
+
"jsDoc": "node scripts/jsDoc.mjs",
|
|
65
|
+
"count": "node scripts/exports.mjs"
|
|
64
66
|
}
|
|
65
67
|
}
|