nhb-toolbox 4.25.10 → 4.25.11
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/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ All notable changes to the package will be documented here.
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [4.25.11] - 2025-11-06
|
|
10
|
+
|
|
11
|
+
- **Fixed** *pluralization logic* in `fromNow()` method of `Chronos`: *Only `1` is considered singular, every other number is plural*.
|
|
12
|
+
|
|
9
13
|
## [4.25.10] - 2025-11-06
|
|
10
14
|
|
|
11
15
|
- **Fixed** *pluralization issues* in the methods of `Converter` classes.
|
|
@@ -91,7 +91,7 @@ const fromNowPlugin = (ChronosClass) => {
|
|
|
91
91
|
suffix = ' ago';
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
return `${prefix}${parts.length ? parts?.join(' ') : `0 ${level}`}${suffix}`;
|
|
94
|
+
return `${prefix}${parts.length ? parts?.join(' ') : `0 ${level}s`}${suffix}`;
|
|
95
95
|
};
|
|
96
96
|
};
|
|
97
97
|
exports.fromNowPlugin = fromNowPlugin;
|
|
@@ -188,7 +188,7 @@ export declare class Chronos {
|
|
|
188
188
|
*
|
|
189
189
|
* - Supported format tokens include: `YYYY`, `YY`, `mmmm`, `mmm`, `MM`, `M`, `DD`, `D`, `dd`, `ddd`, `Do`, `HH`, `H`, `hh`, `h`, `mm`, `m`, `ss`, `s`, `ms`, `mss`, `a`, `A`, and `ZZ`.
|
|
190
190
|
* - *Any token not wrapped in brackets will be parsed and replaced with its corresponding date component.*
|
|
191
|
-
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/format#format-tokens format tokens} for
|
|
191
|
+
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/format#format-tokens format tokens} for details.
|
|
192
192
|
*
|
|
193
193
|
* @param useUTC - Optional boolean to format the date using UTC time.
|
|
194
194
|
* When `true`, it behaves like `formatUTC()` and outputs time based on UTC offset. Defaults to `false`.
|
|
@@ -200,11 +200,11 @@ export declare class Chronos {
|
|
|
200
200
|
/**
|
|
201
201
|
* @instance Formats the date into a predefined strict string format using local time or UTC.
|
|
202
202
|
*
|
|
203
|
-
* @remarks Offers `over
|
|
203
|
+
* @remarks Offers `over 26,500` predefined formats with full IntelliSense support.
|
|
204
204
|
*
|
|
205
205
|
* @param format - The desired format string. Defaults to `'dd, mmm DD, YYYY HH:mm:ss'`
|
|
206
206
|
* (e.g., `'Sun, Apr 06, 2025 16:11:55'`).
|
|
207
|
-
*
|
|
207
|
+
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/format#format-tokens format tokens} for details.
|
|
208
208
|
*
|
|
209
209
|
* @param useUTC - If `true`, formats the date in UTC (equivalent to `formatUTC()`).
|
|
210
210
|
* Defaults to `false` (local time).
|
|
@@ -221,7 +221,7 @@ export declare class Chronos {
|
|
|
221
221
|
*
|
|
222
222
|
* - Supported format tokens include: `YYYY`, `YY`, `mmmm`, `mmm`, `MM`, `M`, `DD`, `D`, `dd`, `ddd`, `Do`, `HH`, `H`, `hh`, `h`, `mm`, `m`, `ss`, `s`, `ms`, `mss`, `a`, `A`, and `ZZ`.
|
|
223
223
|
* - *Any token not wrapped in brackets will be parsed and replaced with its corresponding date component.*
|
|
224
|
-
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/format#format-tokens format tokens} for
|
|
224
|
+
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/format#format-tokens format tokens} for details.
|
|
225
225
|
*
|
|
226
226
|
* @returns Formatted date string in desired format (UTC time).
|
|
227
227
|
*/
|
|
@@ -527,7 +527,7 @@ export declare class Chronos {
|
|
|
527
527
|
* @param options - Configuration for the date range. Accepts a fixed (`RangeWithDates`) format.
|
|
528
528
|
* @returns Array of ISO date strings in either local or UTC format, excluding any skipped weekdays if specified.
|
|
529
529
|
*
|
|
530
|
-
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/calculation#getdatesinrange the documentation site} for
|
|
530
|
+
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/calculation#getdatesinrange the documentation site} for details.
|
|
531
531
|
*
|
|
532
532
|
* @example
|
|
533
533
|
* // Using a fixed date range:
|
|
@@ -555,7 +555,7 @@ export declare class Chronos {
|
|
|
555
555
|
* @param options - Configuration for the date range. Accepts a relative (`RelativeDateRange`) format.
|
|
556
556
|
* @returns Array of ISO date strings in either local or UTC format, excluding any skipped weekdays if specified.
|
|
557
557
|
*
|
|
558
|
-
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/calculation#getdatesinrange the documentation site} for
|
|
558
|
+
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/calculation#getdatesinrange the documentation site} for details.
|
|
559
559
|
*
|
|
560
560
|
* @example
|
|
561
561
|
* // Using a relative date range with skipDays:
|
|
@@ -684,7 +684,7 @@ export declare class Chronos {
|
|
|
684
684
|
* @param options - Relative range (e.g., 7 days, 4 weeks) and output format (local with timezone or utc).
|
|
685
685
|
* @returns Array of ISO date strings in the specified format. Returns empty array if no matches in the time span.
|
|
686
686
|
*
|
|
687
|
-
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/statics#getdatesforday the documentation site} for
|
|
687
|
+
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/statics#getdatesforday the documentation site} for details.
|
|
688
688
|
*
|
|
689
689
|
* @example
|
|
690
690
|
* Chronos.getDatesForDay('Wednesday', { span: 7, unit: 'day' });
|
|
@@ -706,7 +706,7 @@ export declare class Chronos {
|
|
|
706
706
|
* @param options - Date range (from/to, e.g. `'2025-06-30'`, ` new Date()`, `new Chronos()` etc.) and output format (local with timezone or utc).
|
|
707
707
|
* @returns Array of ISO date strings in the specified format. Returns empty array if no matches in the range.
|
|
708
708
|
*
|
|
709
|
-
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/statics#getdatesforday the documentation site} for
|
|
709
|
+
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/statics#getdatesforday the documentation site} for details.
|
|
710
710
|
*
|
|
711
711
|
* @example
|
|
712
712
|
* Chronos.getDatesForDay('Monday', {
|
package/dist/dts/date/types.d.ts
CHANGED
|
@@ -75,9 +75,10 @@ export type ChronosFormat = Year | Month | Day | MonthDate | Hour | Minute | Sec
|
|
|
75
75
|
export type DateParts = `${MonthDate} ${Exclude<Month, 'M' | 'MM'>}` | `${Exclude<Month, 'M' | 'MM'>} ${MonthDate}` | `${Day}, ${MonthDate} ${Exclude<Month, 'M' | 'MM'>}` | `${Day}, ${Exclude<Month, 'M' | 'MM'>} ${MonthDate}` | `${Exclude<Month, 'M' | 'MM'>} ${MonthDate}, ${Year}` | `${MonthDate} ${Exclude<Month, 'M' | 'MM'>}, ${Year}` | `${Exclude<Month, 'M' | 'MM'>} ${MonthDate} ${Year}` | `${MonthDate} ${Exclude<Month, 'M' | 'MM'>} ${Year}` | `${Day}, ${Exclude<Month, 'M' | 'MM'>} ${MonthDate}, ${Year}` | `${Day}, ${MonthDate} ${Exclude<Month, 'M' | 'MM'>}, ${Year}` | `${Day}, ${Exclude<Month, 'M' | 'MM'>} ${MonthDate} ${Year}` | `${Day}, ${MonthDate} ${Exclude<Month, 'M' | 'MM'>} ${Year}` | `${Exclude<MonthDate, 'Do'>}.${Exclude<Month, 'mmm' | 'mmmm'>}.${Year}` | `${Year}.${Exclude<Month, 'mmm' | 'mmmm'>}.${Exclude<MonthDate, 'Do'>}` | `${Exclude<MonthDate, 'Do'>}/${Exclude<Month, 'mmm' | 'mmmm'>}/${Year}` | `${Exclude<MonthDate, 'Do'>}-${Exclude<Month, 'mmm' | 'mmmm'>}-${Year}` | `${Exclude<Month, 'mmm' | 'mmmm'>}/${Exclude<MonthDate, 'Do'>}/${Year}` | `${Exclude<Month, 'mmm' | 'mmmm'>}-${Exclude<MonthDate, 'Do'>}-${Year}` | `${Year}-${Exclude<Month, 'mmm' | 'mmmm'>}-${Exclude<MonthDate, 'Do'>}` | `${Year}/${Exclude<Month, 'mmm' | 'mmmm'>}/${Exclude<MonthDate, 'Do'>}` | `${Year}-${Exclude<MonthDate, 'Do'>}-${Exclude<Month, 'mmm' | 'mmmm'>}` | `${Year}/${Exclude<MonthDate, 'Do'>}/${Exclude<Month, 'mmm' | 'mmmm'>}`;
|
|
76
76
|
/** Standard Time Formats */
|
|
77
77
|
export type TimeParts = `${Exclude<Hour, 'h' | 'hh' | 'H'>}:${Exclude<Minute, 'm'>}` | `${Exclude<Hour, 'H' | 'HH' | 'h'>}:${Exclude<Minute, 'm'>} ${TimeFormats}` | `${Exclude<Hour, 'h' | 'hh' | 'H'>}:${Exclude<Minute, 'm'>}:${Exclude<Second, 's'>}` | `${Exclude<Hour, 'H' | 'HH' | 'h'>}:${Exclude<Minute, 'm'>}:${Exclude<Second, 's'>} ${TimeFormats}` | `${Exclude<Hour, 'h' | 'hh' | 'H'>}:${Exclude<Minute, 'm'>}:${Exclude<Second, 's'>}:${Exclude<Millisecond, 'ms'>}` | `${Exclude<Hour, 'H' | 'HH' | 'h'>}:${Exclude<Minute, 'm'>}:${Exclude<Second, 's'>}:${Exclude<Millisecond, 'ms'>} ${TimeFormats}`;
|
|
78
|
-
type DateTimeConnector = ' ' | ', ' | '; ' | ' - ';
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
type DateTimeConnector = ' ' | ', ' | '; ' | ' - ' | 'T';
|
|
79
|
+
type DateTimeISO = 'YYYY-MM-DDTHH:mm:ss.mssZZ';
|
|
80
|
+
/** Pre-defined literal types for formatting date and time. Optionally can pass any string. */
|
|
81
|
+
export type StrictFormat = LooseLiteral<DateTimeISO | DateParts | TimeParts | `${DateParts}${DateTimeConnector}${TimeParts}`>;
|
|
81
82
|
/** Iterable `Chronos` object properties */
|
|
82
83
|
export interface ChronosObject {
|
|
83
84
|
/** Full year (e.g., 2025). */
|
|
@@ -216,7 +217,16 @@ export type $UTCOffset = `${PositiveUTCHour | NegativeUTCHour}:${UTCMinute}`;
|
|
|
216
217
|
export type UTCOffSet = `UTC${$UTCOffset}`;
|
|
217
218
|
/** `Chronos` Date Format options */
|
|
218
219
|
export interface FormatOptions {
|
|
219
|
-
/**
|
|
220
|
+
/**
|
|
221
|
+
* * The desired format (Default format is `'dd, MMM DD, YYYY HH:mm:ss'` = `'Sun, Apr 06, 2025 16:11:55'`).
|
|
222
|
+
*
|
|
223
|
+
* - To output raw text (i.e., not interpreted as a date token), wrap it in square brackets.
|
|
224
|
+
* - For example, `[Today is] ddd` results in `Today is Sunday`, and `YYYY[ year]` results in `2025 year`.
|
|
225
|
+
*
|
|
226
|
+
* - Supported format tokens include: `YYYY`, `YY`, `mmmm`, `mmm`, `MM`, `M`, `DD`, `D`, `dd`, `ddd`, `Do`, `HH`, `H`, `hh`, `h`, `mm`, `m`, `ss`, `s`, `ms`, `mss`, `a`, `A`, and `ZZ`.
|
|
227
|
+
* - *Any token not wrapped in brackets will be parsed and replaced with its corresponding date component.*
|
|
228
|
+
* - Please refer to {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/format#format-tokens format tokens} for details.
|
|
229
|
+
*/
|
|
220
230
|
format?: string;
|
|
221
231
|
/** - Whether to use UTC time. Defaults to `false`. */
|
|
222
232
|
useUTC?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.11",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|