nhb-toolbox 4.10.94 → 4.10.95
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/chronos.js +24 -24
- package/dist/chronos.js.map +1 -1
- package/dist/chronos.mjs +1 -1
- package/dist/{chunk-A3IVL2GG.js → chunk-1.js} +2 -2
- package/dist/chunk-1.js.map +1 -0
- package/dist/{chunk-NXKPAHR6.mjs → chunk-1.mjs} +2 -2
- package/dist/chunk-1.mjs.map +1 -0
- package/dist/index.js +182 -182
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +8 -1
- package/dist/chunk-A3IVL2GG.js.map +0 -1
- package/dist/chunk-NXKPAHR6.mjs.map +0 -1
package/dist/chronos.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk1_js = require('./chunk-1.js');
|
|
4
4
|
|
|
5
5
|
// src/date/constants.ts
|
|
6
6
|
var DAYS = /* @__PURE__ */ Object.freeze([
|
|
@@ -646,7 +646,7 @@ var Chronos = class _Chronos {
|
|
|
646
646
|
ddd: DAYS[day],
|
|
647
647
|
D: String(date),
|
|
648
648
|
DD: String(date).padStart(2, "0"),
|
|
649
|
-
Do:
|
|
649
|
+
Do: chunk1_js.getOrdinal(date),
|
|
650
650
|
H: String(hours),
|
|
651
651
|
HH: String(hours).padStart(2, "0"),
|
|
652
652
|
h: String(hours % 12 || 12),
|
|
@@ -977,12 +977,12 @@ var Chronos = class _Chronos {
|
|
|
977
977
|
timeZone(zone) {
|
|
978
978
|
let targetOffset;
|
|
979
979
|
let stringOffset;
|
|
980
|
-
if (
|
|
981
|
-
targetOffset =
|
|
980
|
+
if (chunk1_js.isValidUTCOffSet(zone)) {
|
|
981
|
+
targetOffset = chunk1_js.extractMinutesFromUTC(zone);
|
|
982
982
|
stringOffset = zone;
|
|
983
983
|
} else {
|
|
984
984
|
targetOffset = TIME_ZONES[zone] ?? TIME_ZONES["UTC"];
|
|
985
|
-
stringOffset =
|
|
985
|
+
stringOffset = chunk1_js.formatUTCOffset(targetOffset);
|
|
986
986
|
}
|
|
987
987
|
const previousOffset = this.getTimeZoneOffsetMinutes();
|
|
988
988
|
const relativeOffset = targetOffset - previousOffset;
|
|
@@ -999,7 +999,7 @@ var Chronos = class _Chronos {
|
|
|
999
999
|
*/
|
|
1000
1000
|
isLeapYear() {
|
|
1001
1001
|
const year = this.#date.getFullYear();
|
|
1002
|
-
return
|
|
1002
|
+
return chunk1_js.isLeapYear(year);
|
|
1003
1003
|
}
|
|
1004
1004
|
/** @instance Checks if the current date is today. */
|
|
1005
1005
|
isToday() {
|
|
@@ -1208,7 +1208,7 @@ var Chronos = class _Chronos {
|
|
|
1208
1208
|
isPalindromeDate(shortYear = false) {
|
|
1209
1209
|
const padded = this.formatStrict(shortYear ? "YY-MM-DD" : "YYYY-MM-DD");
|
|
1210
1210
|
const normal = this.formatStrict(shortYear ? "YY-M-D" : "YYYY-M-D");
|
|
1211
|
-
return
|
|
1211
|
+
return chunk1_js.isPalindrome(padded) || chunk1_js.isPalindrome(normal);
|
|
1212
1212
|
}
|
|
1213
1213
|
/**
|
|
1214
1214
|
* @instance Checks if the date is within daylight saving time (DST).
|
|
@@ -1286,25 +1286,25 @@ var Chronos = class _Chronos {
|
|
|
1286
1286
|
const lvlIdx = unitOrder.indexOf(level);
|
|
1287
1287
|
const parts = [];
|
|
1288
1288
|
if (lvlIdx >= 0 && years > 0 && lvlIdx >= unitOrder.indexOf("year")) {
|
|
1289
|
-
parts?.push(
|
|
1289
|
+
parts?.push(chunk1_js.formatUnitWithPlural(years, "year"));
|
|
1290
1290
|
}
|
|
1291
1291
|
if (lvlIdx >= unitOrder.indexOf("month") && months > 0) {
|
|
1292
|
-
parts?.push(
|
|
1292
|
+
parts?.push(chunk1_js.formatUnitWithPlural(months, "month"));
|
|
1293
1293
|
}
|
|
1294
1294
|
if (lvlIdx >= unitOrder.indexOf("week") && weeks > 0) {
|
|
1295
|
-
parts?.push(
|
|
1295
|
+
parts?.push(chunk1_js.formatUnitWithPlural(weeks, "week"));
|
|
1296
1296
|
}
|
|
1297
1297
|
if (lvlIdx >= unitOrder.indexOf("day") && days > 0) {
|
|
1298
|
-
parts?.push(
|
|
1298
|
+
parts?.push(chunk1_js.formatUnitWithPlural(days, "day"));
|
|
1299
1299
|
}
|
|
1300
1300
|
if (lvlIdx >= unitOrder.indexOf("hour") && hours > 0) {
|
|
1301
|
-
parts?.push(
|
|
1301
|
+
parts?.push(chunk1_js.formatUnitWithPlural(hours, "hour"));
|
|
1302
1302
|
}
|
|
1303
1303
|
if (lvlIdx >= unitOrder.indexOf("minute") && minutes > 0) {
|
|
1304
|
-
parts?.push(
|
|
1304
|
+
parts?.push(chunk1_js.formatUnitWithPlural(minutes, "minute"));
|
|
1305
1305
|
}
|
|
1306
1306
|
if (lvlIdx >= unitOrder.indexOf("second") && (seconds > 0 || parts?.length === 0)) {
|
|
1307
|
-
parts?.push(
|
|
1307
|
+
parts?.push(chunk1_js.formatUnitWithPlural(seconds, "second"));
|
|
1308
1308
|
}
|
|
1309
1309
|
let prefix = "";
|
|
1310
1310
|
let suffix = "";
|
|
@@ -1906,7 +1906,7 @@ var Chronos = class _Chronos {
|
|
|
1906
1906
|
* @returns The UTC offset in minutes maintaining the current timezone regardless of system having different one.
|
|
1907
1907
|
*/
|
|
1908
1908
|
getTimeZoneOffsetMinutes() {
|
|
1909
|
-
return
|
|
1909
|
+
return chunk1_js.extractMinutesFromUTC(this.#offset);
|
|
1910
1910
|
}
|
|
1911
1911
|
/** @instance Returns new Chronos instance in UTC */
|
|
1912
1912
|
toUTC() {
|
|
@@ -2036,31 +2036,31 @@ var Chronos = class _Chronos {
|
|
|
2036
2036
|
const date = new Date(this.#date);
|
|
2037
2037
|
switch (unit) {
|
|
2038
2038
|
case "millisecond": {
|
|
2039
|
-
const rounded =
|
|
2039
|
+
const rounded = chunk1_js.roundToNearest(date.getMilliseconds(), nearest);
|
|
2040
2040
|
date.setMilliseconds(rounded);
|
|
2041
2041
|
break;
|
|
2042
2042
|
}
|
|
2043
2043
|
case "second": {
|
|
2044
2044
|
const fullSecond = date.getSeconds() + date.getMilliseconds() / 1e3;
|
|
2045
|
-
const rounded =
|
|
2045
|
+
const rounded = chunk1_js.roundToNearest(fullSecond, nearest);
|
|
2046
2046
|
date.setSeconds(rounded, 0);
|
|
2047
2047
|
break;
|
|
2048
2048
|
}
|
|
2049
2049
|
case "minute": {
|
|
2050
2050
|
const fullMinute = date.getMinutes() + date.getSeconds() / 60 + date.getMilliseconds() / 6e4;
|
|
2051
|
-
const rounded =
|
|
2051
|
+
const rounded = chunk1_js.roundToNearest(fullMinute, nearest);
|
|
2052
2052
|
date.setMinutes(rounded, 0, 0);
|
|
2053
2053
|
break;
|
|
2054
2054
|
}
|
|
2055
2055
|
case "hour": {
|
|
2056
2056
|
const fullHour = date.getHours() + date.getMinutes() / 60 + date.getSeconds() / 3600 + date.getMilliseconds() / 36e5;
|
|
2057
|
-
const rounded =
|
|
2057
|
+
const rounded = chunk1_js.roundToNearest(fullHour, nearest);
|
|
2058
2058
|
date.setHours(rounded, 0, 0, 0);
|
|
2059
2059
|
break;
|
|
2060
2060
|
}
|
|
2061
2061
|
case "day": {
|
|
2062
2062
|
const fullDay = date.getDate() + (date.getHours() / 24 + date.getMinutes() / 1440 + date.getSeconds() / 86400 + date.getMilliseconds() / 864e5);
|
|
2063
|
-
const rounded =
|
|
2063
|
+
const rounded = chunk1_js.roundToNearest(fullDay, nearest);
|
|
2064
2064
|
date.setDate(rounded);
|
|
2065
2065
|
date.setHours(0, 0, 0, 0);
|
|
2066
2066
|
break;
|
|
@@ -2084,7 +2084,7 @@ var Chronos = class _Chronos {
|
|
|
2084
2084
|
}
|
|
2085
2085
|
case "month": {
|
|
2086
2086
|
const fullMonth = date.getMonth() + date.getDate() / this.lastDateOfMonth;
|
|
2087
|
-
const roundedMonth =
|
|
2087
|
+
const roundedMonth = chunk1_js.roundToNearest(fullMonth, nearest);
|
|
2088
2088
|
date.setMonth(roundedMonth, 1);
|
|
2089
2089
|
date.setHours(0, 0, 0, 0);
|
|
2090
2090
|
break;
|
|
@@ -2096,7 +2096,7 @@ var Chronos = class _Chronos {
|
|
|
2096
2096
|
const isLeap = new Date(date.getFullYear(), 1, 29).getDate() === 29;
|
|
2097
2097
|
const totalDays = isLeap ? 366 : 365;
|
|
2098
2098
|
const fullYear = date.getFullYear() + dayOfYear / totalDays;
|
|
2099
|
-
const roundedYear =
|
|
2099
|
+
const roundedYear = chunk1_js.roundToNearest(fullYear, nearest);
|
|
2100
2100
|
date.setFullYear(roundedYear, 0, 1);
|
|
2101
2101
|
date.setHours(0, 0, 0, 0);
|
|
2102
2102
|
break;
|
|
@@ -2292,7 +2292,7 @@ var Chronos = class _Chronos {
|
|
|
2292
2292
|
} else {
|
|
2293
2293
|
year = date instanceof _Chronos ? date.year : new _Chronos(date).year;
|
|
2294
2294
|
}
|
|
2295
|
-
return
|
|
2295
|
+
return chunk1_js.isLeapYear(year);
|
|
2296
2296
|
}
|
|
2297
2297
|
/**
|
|
2298
2298
|
* @static Checks if the given value is a valid `Date` object.
|
|
@@ -2312,7 +2312,7 @@ var Chronos = class _Chronos {
|
|
|
2312
2312
|
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
2313
2313
|
*/
|
|
2314
2314
|
static isDateString(value) {
|
|
2315
|
-
return
|
|
2315
|
+
return chunk1_js.isString(value) && !isNaN(Date.parse(value));
|
|
2316
2316
|
}
|
|
2317
2317
|
/**
|
|
2318
2318
|
* @static Checks if the given value is an instance of `Chronos`.
|