nhb-toolbox 4.20.90 → 4.20.91
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,10 +6,14 @@ All notable changes to the package will be documented here.
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [4.20.91] - 2025-10-12
|
|
10
|
+
|
|
11
|
+
- **Updated** _tsdoc_ for `fromNow()` `Chronos` method: modified _@remarks_ section.
|
|
12
|
+
|
|
9
13
|
## [4.20.90] - 2025-10-12
|
|
10
14
|
|
|
11
15
|
- **Updated** `formatUnitWithPlural` utility: now returns _singular unit_ for both `0` and `1`.
|
|
12
|
-
- **
|
|
16
|
+
- **Updated** `fromNow()` `Chronos` method: **fixed** issues when provided unit level value is `0`.
|
|
13
17
|
|
|
14
18
|
## [4.20.89] - 2025-10-12
|
|
15
19
|
|
|
@@ -5,7 +5,7 @@ const convert_1 = require("../../string/convert");
|
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const fromNowPlugin = (ChronosClass) => {
|
|
7
7
|
const internal = ChronosClass[constants_1.INTERNALS];
|
|
8
|
-
ChronosClass.prototype.fromNow = function (level = '
|
|
8
|
+
ChronosClass.prototype.fromNow = function (level = 'second', withSuffixPrefix = true, time) {
|
|
9
9
|
const now = internal.toNewDate(this, time);
|
|
10
10
|
const target = internal.internalDate(this);
|
|
11
11
|
const isFuture = target > now;
|
|
@@ -5,14 +5,14 @@ declare module '../Chronos' {
|
|
|
5
5
|
/**
|
|
6
6
|
* @instance Returns full time difference from now (or a specified time) down to a given level.
|
|
7
7
|
*
|
|
8
|
-
* @param level Determines the smallest unit to include in the output (e.g., 'minute' will show up to minutes, ignoring seconds). Defaults to `
|
|
8
|
+
* @param level Determines the smallest unit to include in the output (e.g., 'minute' will show up to minutes, ignoring seconds). Defaults to `second`.
|
|
9
9
|
* @param withSuffixPrefix If `true`, adds `"in"` or `"ago"` depending on whether the time is in the future or past. Defaults to `true`.
|
|
10
10
|
* @param time An optional time value to compare with (`string`, `number`, `Date`, or `Chronos` instance). Defaults to `now`.
|
|
11
11
|
* @returns The difference as a human-readable string, e.g., `2 years 1 month 9 days 18 hours 56 minutes ago`.
|
|
12
12
|
*
|
|
13
13
|
* @remarks
|
|
14
14
|
* - This method calculates the **elapsed time difference** (exclusive of the end day), consistent with libraries like `Day.js` and `Luxon`.
|
|
15
|
-
* - If you need an *inclusive calendar-style* difference (counting both start and end days),
|
|
15
|
+
* - If you need an *inclusive calendar-style* difference (counting both start and end days), adjust one day manually before calling `fromNow()`.
|
|
16
16
|
*/
|
|
17
17
|
fromNow(level?: FromNowUnit, withSuffixPrefix?: boolean, time?: ChronosInput): string;
|
|
18
18
|
}
|
|
@@ -2,7 +2,7 @@ import { formatUnitWithPlural } from '../../string/convert.js';
|
|
|
2
2
|
import { INTERNALS } from '../constants.js';
|
|
3
3
|
export const fromNowPlugin = (ChronosClass) => {
|
|
4
4
|
const internal = ChronosClass[INTERNALS];
|
|
5
|
-
ChronosClass.prototype.fromNow = function (level = '
|
|
5
|
+
ChronosClass.prototype.fromNow = function (level = 'second', withSuffixPrefix = true, time) {
|
|
6
6
|
const now = internal.toNewDate(this, time);
|
|
7
7
|
const target = internal.internalDate(this);
|
|
8
8
|
const isFuture = target > now;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.20.
|
|
3
|
+
"version": "4.20.91",
|
|
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",
|