chronos-date 2.0.4 → 2.1.0
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/constants.d.mts +1 -1
- package/dist/convert-C8LsoKmI-Blf3eLS6.mjs +285 -0
- package/dist/convert-C8LsoKmI-uBhT5hZQ.cjs +387 -0
- package/dist/dist-BPHYJA0t.mjs +70 -0
- package/dist/dist-CdMlZMZa.cjs +75 -0
- package/dist/{greet-DNGvP7nm.mjs → greet-BC86-X9W.mjs} +2 -2
- package/dist/{greet-CMkwXJ7o.cjs → greet-Brz0CVv1.cjs} +8 -8
- package/dist/guards-DTI799nG.mjs +46 -0
- package/dist/guards-dH9JJIso.cjs +51 -0
- package/dist/guards.cjs +14 -16
- package/dist/guards.d.cts +1 -1
- package/dist/guards.d.mts +1 -1
- package/dist/guards.mjs +1 -3
- package/dist/{helpers-Bq7Hczoa.cjs → helpers-BMDeRLjO.cjs} +6 -8
- package/dist/{helpers-C2spzGZ-.mjs → helpers-t49KkxOE.mjs} +2 -4
- package/dist/index.cjs +13 -14
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -5
- package/dist/plugins/banglaPlugin.cjs +16 -33
- package/dist/plugins/banglaPlugin.d.cts +1 -1
- package/dist/plugins/banglaPlugin.d.mts +1 -1
- package/dist/plugins/banglaPlugin.mjs +2 -19
- package/dist/plugins/businessPlugin.cjs +4 -5
- package/dist/plugins/businessPlugin.d.cts +1 -1
- package/dist/plugins/businessPlugin.d.mts +1 -1
- package/dist/plugins/businessPlugin.mjs +1 -2
- package/dist/plugins/dateRangePlugin.cjs +4 -5
- package/dist/plugins/dateRangePlugin.d.cts +1 -1
- package/dist/plugins/dateRangePlugin.d.mts +1 -1
- package/dist/plugins/dateRangePlugin.mjs +1 -2
- package/dist/plugins/dayPartPlugin.cjs +2 -2
- package/dist/plugins/dayPartPlugin.d.cts +1 -1
- package/dist/plugins/dayPartPlugin.d.mts +1 -1
- package/dist/plugins/dayPartPlugin.mjs +1 -1
- package/dist/plugins/durationPlugin.d.cts +1 -1
- package/dist/plugins/durationPlugin.d.mts +1 -1
- package/dist/plugins/fromNowPlugin.cjs +2 -2
- package/dist/plugins/fromNowPlugin.d.cts +1 -1
- package/dist/plugins/fromNowPlugin.d.mts +1 -1
- package/dist/plugins/fromNowPlugin.mjs +1 -1
- package/dist/plugins/greetingPlugin.cjs +1 -1
- package/dist/plugins/greetingPlugin.d.cts +1 -1
- package/dist/plugins/greetingPlugin.d.mts +1 -1
- package/dist/plugins/greetingPlugin.mjs +1 -1
- package/dist/plugins/palindromePlugin.cjs +2 -9
- package/dist/plugins/palindromePlugin.d.cts +1 -1
- package/dist/plugins/palindromePlugin.d.mts +1 -1
- package/dist/plugins/palindromePlugin.mjs +1 -8
- package/dist/plugins/relativeTimePlugin.d.cts +1 -1
- package/dist/plugins/relativeTimePlugin.d.mts +1 -1
- package/dist/plugins/roundPlugin.cjs +8 -8
- package/dist/plugins/roundPlugin.d.cts +1 -1
- package/dist/plugins/roundPlugin.d.mts +1 -1
- package/dist/plugins/roundPlugin.mjs +1 -1
- package/dist/plugins/seasonPlugin.d.cts +1 -1
- package/dist/plugins/seasonPlugin.d.mts +1 -1
- package/dist/plugins/timeZonePlugin.cjs +3 -3
- package/dist/plugins/timeZonePlugin.d.cts +1 -1
- package/dist/plugins/timeZonePlugin.d.mts +1 -1
- package/dist/plugins/timeZonePlugin.mjs +2 -2
- package/dist/plugins/zodiacPlugin.cjs +1 -1
- package/dist/plugins/zodiacPlugin.d.cts +1 -1
- package/dist/plugins/zodiacPlugin.d.mts +1 -1
- package/dist/plugins/zodiacPlugin.mjs +1 -1
- package/dist/{types-Be4ZMpOV.d.mts → types-CiFnGEL8.d.mts} +967 -902
- package/dist/{types-dNpvroNQ.d.cts → types-zhhEJ8N7.d.cts} +966 -901
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/{utilities-C6NiChRE.mjs → utils-DBy7S7hH.mjs} +3 -5
- package/dist/{utilities-CCnKWAsS.cjs → utils-S_aw0TeC.cjs} +8 -10
- package/dist/utils.cjs +33 -34
- package/dist/utils.d.cts +4 -4
- package/dist/utils.d.mts +4 -4
- package/dist/utils.mjs +4 -5
- package/package.json +3 -3
- package/dist/convert-BDQBTK5P.cjs +0 -49
- package/dist/convert-D5Cd0cCg.mjs +0 -38
- package/dist/non-primitives-BqjRwK2B.cjs +0 -68
- package/dist/non-primitives-CbAOB6lb.mjs +0 -38
- package/dist/primitives-BXhrgs9R.mjs +0 -35
- package/dist/primitives-DfO90c3G.cjs +0 -65
- package/dist/utilities-BnHD2hHf.mjs +0 -59
- package/dist/utilities-C_KmjIRK.cjs +0 -88
- /package/dist/{seasons-B_kjFWIX.d.mts → seasons-DYk2jvtn.d.mts} +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { c as isNumericString, f as BN_DIGITS, h as isNumber, m as isNonEmptyString } from "./convert-C8LsoKmI-Blf3eLS6.mjs";
|
|
18
|
+
|
|
19
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/index.mjs
|
|
20
|
+
/**
|
|
21
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
24
|
+
* you may not use this file except in compliance with the License.
|
|
25
|
+
* You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* * Converts Latin (Arabic system) digits to Bangla digits (Arabic system).
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* - Accepts numbers or numeric strings including non-digit characters.
|
|
40
|
+
* - When `preserveNonDigit` is `true`, non-digit characters are preserved in the output.
|
|
41
|
+
* - When `preserveNonDigit` is `false`, non-numeric strings are stripped.
|
|
42
|
+
* - Returns empty string for invalid input.
|
|
43
|
+
*
|
|
44
|
+
* @param digit - A number or string containing Latin (Arabic system) digits.
|
|
45
|
+
* @param preserveNonDigit - Whether to preserve non-digit characters in the output. Default is `true`.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* digitToBangla(123); // "১২৩"
|
|
49
|
+
* digitToBangla('456'); // "৪৫৬"
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* digitToBangla('12ab', false); // "১২"
|
|
53
|
+
* digitToBangla('12ab'); // "১২ab"
|
|
54
|
+
*/
|
|
55
|
+
function digitToBangla(digit, preserveNonDigit = true) {
|
|
56
|
+
const banglaDigits = Object.keys(BN_DIGITS);
|
|
57
|
+
const _matchAndConvert = (value) => {
|
|
58
|
+
return value.replace(/\d/g, (dig) => banglaDigits[Number(dig)]);
|
|
59
|
+
};
|
|
60
|
+
if (isNumber(digit)) return _matchAndConvert(String(digit));
|
|
61
|
+
if (isNonEmptyString(digit)) {
|
|
62
|
+
const bnDigStr = _matchAndConvert(digit);
|
|
63
|
+
if (preserveNonDigit || isNumericString(digit)) return bnDigStr;
|
|
64
|
+
return bnDigStr.split("").filter((dig) => banglaDigits.includes(dig)).join("");
|
|
65
|
+
}
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
export { digitToBangla as t };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const require_convert_C8LsoKmI = require('./convert-C8LsoKmI-uBhT5hZQ.cjs');
|
|
18
|
+
|
|
19
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/index.mjs
|
|
20
|
+
/**
|
|
21
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
24
|
+
* you may not use this file except in compliance with the License.
|
|
25
|
+
* You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* * Converts Latin (Arabic system) digits to Bangla digits (Arabic system).
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* - Accepts numbers or numeric strings including non-digit characters.
|
|
40
|
+
* - When `preserveNonDigit` is `true`, non-digit characters are preserved in the output.
|
|
41
|
+
* - When `preserveNonDigit` is `false`, non-numeric strings are stripped.
|
|
42
|
+
* - Returns empty string for invalid input.
|
|
43
|
+
*
|
|
44
|
+
* @param digit - A number or string containing Latin (Arabic system) digits.
|
|
45
|
+
* @param preserveNonDigit - Whether to preserve non-digit characters in the output. Default is `true`.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* digitToBangla(123); // "১২৩"
|
|
49
|
+
* digitToBangla('456'); // "৪৫৬"
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* digitToBangla('12ab', false); // "১২"
|
|
53
|
+
* digitToBangla('12ab'); // "১২ab"
|
|
54
|
+
*/
|
|
55
|
+
function digitToBangla(digit, preserveNonDigit = true) {
|
|
56
|
+
const banglaDigits = Object.keys(require_convert_C8LsoKmI.BN_DIGITS);
|
|
57
|
+
const _matchAndConvert = (value) => {
|
|
58
|
+
return value.replace(/\d/g, (dig) => banglaDigits[Number(dig)]);
|
|
59
|
+
};
|
|
60
|
+
if (require_convert_C8LsoKmI.isNumber(digit)) return _matchAndConvert(String(digit));
|
|
61
|
+
if (require_convert_C8LsoKmI.isNonEmptyString(digit)) {
|
|
62
|
+
const bnDigStr = _matchAndConvert(digit);
|
|
63
|
+
if (preserveNonDigit || require_convert_C8LsoKmI.isNumericString(digit)) return bnDigStr;
|
|
64
|
+
return bnDigStr.split("").filter((dig) => banglaDigits.includes(dig)).join("");
|
|
65
|
+
}
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
Object.defineProperty(exports, 'digitToBangla', {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () {
|
|
73
|
+
return digitToBangla;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { isValidTime } from "./guards.mjs";
|
|
18
|
-
import { n as extractHourMinute, p as getTotalMinutes } from "./
|
|
18
|
+
import { n as extractHourMinute, p as getTotalMinutes } from "./utils-DBy7S7hH.mjs";
|
|
19
19
|
|
|
20
|
-
//#region src/
|
|
20
|
+
//#region src/utilities/greet.ts
|
|
21
21
|
/**
|
|
22
22
|
* * Returns a greeting message based on the provided time or current time.
|
|
23
23
|
*
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
const require_guards = require('./guards.cjs');
|
|
18
|
-
const
|
|
18
|
+
const require_utils = require('./utils-S_aw0TeC.cjs');
|
|
19
19
|
|
|
20
|
-
//#region src/
|
|
20
|
+
//#region src/utilities/greet.ts
|
|
21
21
|
/**
|
|
22
22
|
* * Returns a greeting message based on the provided time or current time.
|
|
23
23
|
*
|
|
@@ -28,18 +28,18 @@ function getGreeting(configs) {
|
|
|
28
28
|
const { morningEnds = "11:59", noonEnds = "12:59", afternoonEnds = "17:59", eveningEnds = "23:59", midnightEnds = "02:59", currentTime, appendToMsg = "", prependToMsg = "", morningMessage = "Good Morning!", noonMessage = "Good Noon!", afternoonMessage = "Good Afternoon!", eveningMessage = "Good Evening!", midnightMessage = "Hello, Night Owl!", defaultMessage = "Greetings!" } = configs || {};
|
|
29
29
|
let hour;
|
|
30
30
|
let minute;
|
|
31
|
-
if (currentTime && require_guards.isValidTime(currentTime)) [hour, minute] =
|
|
31
|
+
if (currentTime && require_guards.isValidTime(currentTime)) [hour, minute] = require_utils.extractHourMinute(currentTime);
|
|
32
32
|
else {
|
|
33
33
|
const now = /* @__PURE__ */ new Date();
|
|
34
34
|
hour = now.getHours();
|
|
35
35
|
minute = now.getMinutes();
|
|
36
36
|
}
|
|
37
37
|
const currentTotalMinutes = hour * 60 + minute;
|
|
38
|
-
const morningEndMinutes =
|
|
39
|
-
const noonEndMinutes =
|
|
40
|
-
const afternoonEndMinutes =
|
|
41
|
-
const eveningEndMinutes =
|
|
42
|
-
if (currentTotalMinutes <=
|
|
38
|
+
const morningEndMinutes = require_utils.getTotalMinutes(morningEnds);
|
|
39
|
+
const noonEndMinutes = require_utils.getTotalMinutes(noonEnds);
|
|
40
|
+
const afternoonEndMinutes = require_utils.getTotalMinutes(afternoonEnds);
|
|
41
|
+
const eveningEndMinutes = require_utils.getTotalMinutes(eveningEnds);
|
|
42
|
+
if (currentTotalMinutes <= require_utils.getTotalMinutes(midnightEnds)) return prependToMsg.concat(midnightMessage.concat(appendToMsg));
|
|
43
43
|
else if (currentTotalMinutes <= morningEndMinutes) return prependToMsg.concat(morningMessage.concat(appendToMsg));
|
|
44
44
|
else if (currentTotalMinutes <= noonEndMinutes) return prependToMsg.concat(noonMessage.concat(appendToMsg));
|
|
45
45
|
else if (currentTotalMinutes <= afternoonEndMinutes) return prependToMsg.concat(afternoonMessage.concat(appendToMsg));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { n as reverseString } from "./convert-C8LsoKmI-Blf3eLS6.mjs";
|
|
18
|
+
|
|
19
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/guards.mjs
|
|
20
|
+
/**
|
|
21
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
24
|
+
* you may not use this file except in compliance with the License.
|
|
25
|
+
* You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* * Checks if a string is a palindrome.
|
|
37
|
+
* @param input - The string to check.
|
|
38
|
+
* @returns True if the string is a palindrome, otherwise false.
|
|
39
|
+
*/
|
|
40
|
+
const isPalindrome = (input) => {
|
|
41
|
+
const normalized = input.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
42
|
+
return normalized === reverseString(normalized);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { isPalindrome as t };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const require_convert_C8LsoKmI = require('./convert-C8LsoKmI-uBhT5hZQ.cjs');
|
|
18
|
+
|
|
19
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/guards.mjs
|
|
20
|
+
/**
|
|
21
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
24
|
+
* you may not use this file except in compliance with the License.
|
|
25
|
+
* You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* * Checks if a string is a palindrome.
|
|
37
|
+
* @param input - The string to check.
|
|
38
|
+
* @returns True if the string is a palindrome, otherwise false.
|
|
39
|
+
*/
|
|
40
|
+
const isPalindrome = (input) => {
|
|
41
|
+
const normalized = input.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
42
|
+
return normalized === require_convert_C8LsoKmI.reverseString(normalized);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
Object.defineProperty(exports, 'isPalindrome', {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return isPalindrome;
|
|
50
|
+
}
|
|
51
|
+
});
|
package/dist/guards.cjs
CHANGED
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
18
18
|
const require_timezone = require('./timezone-BNnHFgki.cjs');
|
|
19
|
-
const
|
|
20
|
-
const require_non_primitives = require('./non-primitives-BqjRwK2B.cjs');
|
|
21
|
-
const require_utilities = require('./utilities-C_KmjIRK.cjs');
|
|
19
|
+
const require_convert_C8LsoKmI = require('./convert-C8LsoKmI-uBhT5hZQ.cjs');
|
|
22
20
|
|
|
23
21
|
//#region src/guards.ts
|
|
24
22
|
/**
|
|
@@ -35,7 +33,7 @@ function isDate(value) {
|
|
|
35
33
|
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
36
34
|
*/
|
|
37
35
|
function isDateString(value) {
|
|
38
|
-
return
|
|
36
|
+
return require_convert_C8LsoKmI.isNonEmptyString(value) && !isNaN(Date.parse(value));
|
|
39
37
|
}
|
|
40
38
|
/**
|
|
41
39
|
* * Checks if the provided value is a valid time string in "HH:MM" format.
|
|
@@ -44,9 +42,9 @@ function isDateString(value) {
|
|
|
44
42
|
* @returns `true` if the value is a valid time string, `false` otherwise.
|
|
45
43
|
*/
|
|
46
44
|
function isValidTime(value) {
|
|
47
|
-
if (!
|
|
45
|
+
if (!require_convert_C8LsoKmI.isNonEmptyString(value)) return false;
|
|
48
46
|
const [hourStr, minuteStr] = value.split(":");
|
|
49
|
-
if (!
|
|
47
|
+
if (!require_convert_C8LsoKmI.isNumericString(hourStr) || !require_convert_C8LsoKmI.isNumericString(minuteStr)) return false;
|
|
50
48
|
const hour = Number(hourStr);
|
|
51
49
|
const minute = Number(minuteStr);
|
|
52
50
|
return hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59;
|
|
@@ -58,7 +56,7 @@ function isValidTime(value) {
|
|
|
58
56
|
* @returns `true` if the value is a valid utc offset, `false` otherwise.
|
|
59
57
|
*/
|
|
60
58
|
function isValidUTCOffset(value) {
|
|
61
|
-
return
|
|
59
|
+
return require_convert_C8LsoKmI.isNonEmptyString(value) ? /^UTC[+-]?\d{1,2}:\d{2}$/.test(value) : false;
|
|
62
60
|
}
|
|
63
61
|
/**
|
|
64
62
|
* * Validates whether the provided value is a recognized IANA time zone identifier (excluding `"Factory"`), based on the {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}.
|
|
@@ -71,7 +69,7 @@ function isValidUTCOffset(value) {
|
|
|
71
69
|
* @returns `true` if the value is a valid IANA time zone identifier, otherwise `false`.
|
|
72
70
|
*/
|
|
73
71
|
function isValidTimeZoneId(value) {
|
|
74
|
-
return
|
|
72
|
+
return require_convert_C8LsoKmI.isNonEmptyString(value) ? new Set([...require_timezone.IANA_TZ_IDS]).has(value) : false;
|
|
75
73
|
}
|
|
76
74
|
/**
|
|
77
75
|
* * Validates whether the provided value is a supported time zone identifier using the native JavaScript API (`Intl.supportedValuesOf('timeZone')`).
|
|
@@ -85,7 +83,7 @@ function isValidTimeZoneId(value) {
|
|
|
85
83
|
* @returns `true` if the value is a valid native JS-supported time zone identifier, otherwise `false`.
|
|
86
84
|
*/
|
|
87
85
|
function isNativeTimeZoneId(value) {
|
|
88
|
-
return
|
|
86
|
+
return require_convert_C8LsoKmI.isNonEmptyString(value) ? new Set(require_timezone.NATIVE_TZ_IDS).has(value) : false;
|
|
89
87
|
}
|
|
90
88
|
/**
|
|
91
89
|
* * Checks if the year is a leap year.
|
|
@@ -96,7 +94,7 @@ function isNativeTimeZoneId(value) {
|
|
|
96
94
|
* @returns `true` if the year is a leap year, `false` otherwise.
|
|
97
95
|
*/
|
|
98
96
|
function isLeapYear(year) {
|
|
99
|
-
const $year =
|
|
97
|
+
const $year = require_convert_C8LsoKmI.normalizeNumber(year);
|
|
100
98
|
return $year ? $year % 4 === 0 && $year % 100 !== 0 || $year % 400 === 0 : false;
|
|
101
99
|
}
|
|
102
100
|
/**
|
|
@@ -106,11 +104,11 @@ function isLeapYear(year) {
|
|
|
106
104
|
*/
|
|
107
105
|
function isDateLike(value) {
|
|
108
106
|
if (value instanceof Date) return true;
|
|
109
|
-
if (
|
|
110
|
-
if (
|
|
111
|
-
if (
|
|
112
|
-
if (
|
|
113
|
-
if (
|
|
107
|
+
if (require_convert_C8LsoKmI.isObject(value)) {
|
|
108
|
+
if (require_convert_C8LsoKmI.isFunction(value?.format) && require_convert_C8LsoKmI.isFunction(value?.toJSON) && require_convert_C8LsoKmI.isFunction(value?.toISOString)) return true;
|
|
109
|
+
if (require_convert_C8LsoKmI.isFunction(value?.toISO) && require_convert_C8LsoKmI.isFunction(value?.toFormat) && require_convert_C8LsoKmI.isBoolean(value?.isValid)) return true;
|
|
110
|
+
if (require_convert_C8LsoKmI.isFunction(value?.plus) && require_convert_C8LsoKmI.isFunction(value?.minus) && require_convert_C8LsoKmI.isFunction(value?.equals) && require_convert_C8LsoKmI.isFunction(value?.getClass)) return true;
|
|
111
|
+
if (require_convert_C8LsoKmI.isFunction(value?.toJSON) && require_convert_C8LsoKmI.isFunction(value?.toString) && [
|
|
114
112
|
"Instant",
|
|
115
113
|
"Duration",
|
|
116
114
|
"PlainDate",
|
|
@@ -125,7 +123,7 @@ function isDateLike(value) {
|
|
|
125
123
|
}
|
|
126
124
|
/** Checks if a value represents time value (number) with different forms of {@link TimeWithUnit units} */
|
|
127
125
|
function isTimeWithUnit(value) {
|
|
128
|
-
return
|
|
126
|
+
return require_convert_C8LsoKmI.isNonEmptyString(value) && /^-?\d*\.?\d+ *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.test(value);
|
|
129
127
|
}
|
|
130
128
|
|
|
131
129
|
//#endregion
|
package/dist/guards.d.cts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { En as Numeric, Nt as TimeZoneIdNative, Q as $TimeZoneIdentifier, at as ClockTime, ct as DateLike, kt as TimeWithUnit, zt as UTCOffset } from "./types-zhhEJ8N7.cjs";
|
|
18
18
|
|
|
19
19
|
//#region src/guards.d.ts
|
|
20
20
|
/**
|
package/dist/guards.d.mts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { En as Numeric, Nt as TimeZoneIdNative, Q as $TimeZoneIdentifier, at as ClockTime, ct as DateLike, kt as TimeWithUnit, zt as UTCOffset } from "./types-CiFnGEL8.mjs";
|
|
18
18
|
|
|
19
19
|
//#region src/guards.d.ts
|
|
20
20
|
/**
|
package/dist/guards.mjs
CHANGED
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { n as NATIVE_TZ_IDS, t as IANA_TZ_IDS } from "./timezone-Db2CeL32.mjs";
|
|
18
|
-
import {
|
|
19
|
-
import { r as isObject, t as isFunction } from "./non-primitives-CbAOB6lb.mjs";
|
|
20
|
-
import { a as isNumericString, n as normalizeNumber } from "./utilities-BnHD2hHf.mjs";
|
|
18
|
+
import { c as isNumericString, i as normalizeNumber, l as isObject, m as isNonEmptyString, o as isFunction, p as isBoolean } from "./convert-C8LsoKmI-Blf3eLS6.mjs";
|
|
21
19
|
|
|
22
20
|
//#region src/guards.ts
|
|
23
21
|
/**
|
|
@@ -15,12 +15,10 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
const require_basic = require('./basic-DsQqC5nZ.cjs');
|
|
18
|
-
const
|
|
19
|
-
const require_non_primitives = require('./non-primitives-BqjRwK2B.cjs');
|
|
20
|
-
const require_utilities = require('./utilities-C_KmjIRK.cjs');
|
|
18
|
+
const require_convert_C8LsoKmI = require('./convert-C8LsoKmI-uBhT5hZQ.cjs');
|
|
21
19
|
const require_guards = require('./guards.cjs');
|
|
22
20
|
|
|
23
|
-
//#region src/
|
|
21
|
+
//#region src/utilities/helpers.ts
|
|
24
22
|
/** Core formatting logic shared by `formatDate` and `Chronos`, `BanglaCalendar` classes */
|
|
25
23
|
function _formatDateCore(format, dateComponents) {
|
|
26
24
|
const tokenRegex = new RegExp(`^(${require_basic.SORTED_TIME_FORMATS.join("|")})`);
|
|
@@ -63,7 +61,7 @@ function _formatDate(format, year, month, day, date, hours, minutes, seconds, mi
|
|
|
63
61
|
ddd: require_basic.DAYS[day],
|
|
64
62
|
D: String(date),
|
|
65
63
|
DD: _padZero(date),
|
|
66
|
-
Do:
|
|
64
|
+
Do: require_convert_C8LsoKmI.getOrdinal(date),
|
|
67
65
|
H: String(hours),
|
|
68
66
|
HH: _padZero(hours),
|
|
69
67
|
h: String(hours % 12 || 12),
|
|
@@ -179,7 +177,7 @@ function _padShunno(str, length = 2) {
|
|
|
179
177
|
* @returns A `Date` object representing the input date.
|
|
180
178
|
*/
|
|
181
179
|
function _dateArgsToDate(value) {
|
|
182
|
-
return require_guards.isDate(value) ? value : new Date(
|
|
180
|
+
return require_guards.isDate(value) ? value : new Date(require_convert_C8LsoKmI.isString(value) ? value.replace(/['"]/g, "") : value ?? Date.now());
|
|
183
181
|
}
|
|
184
182
|
/**
|
|
185
183
|
* Type guard to check if a value has the necessary properties to be reconstructed into a `Chronos` instance.
|
|
@@ -188,13 +186,13 @@ function _dateArgsToDate(value) {
|
|
|
188
186
|
* @returns `true` if the value has the required properties for reconstruction, otherwise `false`.
|
|
189
187
|
*/
|
|
190
188
|
function _hasChronosProperties(value) {
|
|
191
|
-
return
|
|
189
|
+
return require_convert_C8LsoKmI.isObjectWithKeys(value, [
|
|
192
190
|
"origin",
|
|
193
191
|
"native",
|
|
194
192
|
"utcOffset",
|
|
195
193
|
"timeZoneName",
|
|
196
194
|
"timeZoneId"
|
|
197
|
-
]) &&
|
|
195
|
+
]) && require_convert_C8LsoKmI.isNonEmptyString(value.origin) && (require_guards.isDate(value.native) || require_guards.isDateString(value.native)) && require_guards.isValidUTCOffset(value.utcOffset) && require_convert_C8LsoKmI.isNonEmptyString(value.timeZoneName) && (require_convert_C8LsoKmI.isNonEmptyString(value.timeZoneId) || require_convert_C8LsoKmI.isValidArray(value.timeZoneId));
|
|
198
196
|
}
|
|
199
197
|
|
|
200
198
|
//#endregion
|
|
@@ -15,12 +15,10 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { c as MONTHS, d as SORTED_TIME_FORMATS, i as BN_SEASONS, o as DAYS, r as BN_MONTH_TABLES, u as MS_PER_DAY } from "./basic-DqKyujoj.mjs";
|
|
18
|
-
import {
|
|
19
|
-
import { a as isValidArray, i as isObjectWithKeys } from "./non-primitives-CbAOB6lb.mjs";
|
|
20
|
-
import { t as getOrdinal } from "./utilities-BnHD2hHf.mjs";
|
|
18
|
+
import { d as isValidArray, g as isString, m as isNonEmptyString, r as getOrdinal, u as isObjectWithKeys } from "./convert-C8LsoKmI-Blf3eLS6.mjs";
|
|
21
19
|
import { isDate, isDateString, isLeapYear, isValidUTCOffset } from "./guards.mjs";
|
|
22
20
|
|
|
23
|
-
//#region src/
|
|
21
|
+
//#region src/utilities/helpers.ts
|
|
24
22
|
/** Core formatting logic shared by `formatDate` and `Chronos`, `BanglaCalendar` classes */
|
|
25
23
|
function _formatDateCore(format, dateComponents) {
|
|
26
24
|
const tokenRegex = new RegExp(`^(${SORTED_TIME_FORMATS.join("|")})`);
|
package/dist/index.cjs
CHANGED
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
18
18
|
const require_basic = require('./basic-DsQqC5nZ.cjs');
|
|
19
|
-
const
|
|
20
|
-
const require_non_primitives = require('./non-primitives-BqjRwK2B.cjs');
|
|
19
|
+
const require_convert_C8LsoKmI = require('./convert-C8LsoKmI-uBhT5hZQ.cjs');
|
|
21
20
|
const require_guards = require('./guards.cjs');
|
|
22
|
-
const require_helpers = require('./helpers-
|
|
23
|
-
const
|
|
21
|
+
const require_helpers = require('./helpers-BMDeRLjO.cjs');
|
|
22
|
+
const require_utils = require('./utils-S_aw0TeC.cjs');
|
|
24
23
|
|
|
25
|
-
//#region src/
|
|
24
|
+
//#region src/utilities/chronos-fn.ts
|
|
26
25
|
/**
|
|
27
26
|
* * Converts a date into a Chronos object and access to all `Chronos` methods and properties.
|
|
28
27
|
*
|
|
@@ -77,7 +76,7 @@ const require_utilities = require('./utilities-CCnKWAsS.cjs');
|
|
|
77
76
|
* ```
|
|
78
77
|
*/
|
|
79
78
|
const $chronos = (valueOrYear, month, date, hours, minutes, seconds, ms) => {
|
|
80
|
-
if (
|
|
79
|
+
if (require_convert_C8LsoKmI.isNumber(valueOrYear) && require_convert_C8LsoKmI.isNumber(month)) return new Chronos(valueOrYear, month, date ?? 1, hours ?? 0, minutes ?? 0, seconds ?? 0, ms ?? 0);
|
|
81
80
|
else return new Chronos(valueOrYear);
|
|
82
81
|
};
|
|
83
82
|
/**
|
|
@@ -87,7 +86,7 @@ const $chronos = (valueOrYear, month, date, hours, minutes, seconds, ms) => {
|
|
|
87
86
|
* @returns `true` if the property is a static method of `Chronos`, `false` otherwise.
|
|
88
87
|
*/
|
|
89
88
|
function _isChronosStaticKey(prop) {
|
|
90
|
-
return prop in Chronos && prop !== "prototype" && prop !== "name" && prop !== "length" &&
|
|
89
|
+
return prop in Chronos && prop !== "prototype" && prop !== "name" && prop !== "length" && require_convert_C8LsoKmI.isFunction(Chronos[prop]);
|
|
91
90
|
}
|
|
92
91
|
/**
|
|
93
92
|
* * Use `chronos` with all static methods from the `Chronos` class.
|
|
@@ -251,7 +250,7 @@ var Chronos = class Chronos {
|
|
|
251
250
|
* @returns Instance of `Chronos` with all methods and properties.
|
|
252
251
|
*/
|
|
253
252
|
constructor(valueOrYear, month, date, hours, minutes, seconds, ms) {
|
|
254
|
-
if (
|
|
253
|
+
if (require_convert_C8LsoKmI.isNumber(valueOrYear) && require_convert_C8LsoKmI.isNumber(month)) {
|
|
255
254
|
this.#date = new Date(valueOrYear, month - 1, date ?? 1, hours ?? 0, minutes ?? 0, seconds ?? 0, ms ?? 0);
|
|
256
255
|
this.native = this.#date;
|
|
257
256
|
} else {
|
|
@@ -318,7 +317,7 @@ var Chronos = class Chronos {
|
|
|
318
317
|
* @returns The resolved time zone name or its IANA identifier as a fallback.
|
|
319
318
|
*/
|
|
320
319
|
$getNativeTimeZoneName(tzId) {
|
|
321
|
-
const $tzId = tzId ||
|
|
320
|
+
const $tzId = tzId || require_utils.getNativeTimeZoneId();
|
|
322
321
|
return require_helpers._resolveNativeTzName($tzId, "long", this.#date) ?? $tzId;
|
|
323
322
|
}
|
|
324
323
|
/**
|
|
@@ -332,7 +331,7 @@ var Chronos = class Chronos {
|
|
|
332
331
|
* @returns The local system's IANA time zone identifier.
|
|
333
332
|
*/
|
|
334
333
|
$getNativeTimeZoneId() {
|
|
335
|
-
return
|
|
334
|
+
return require_utils.getNativeTimeZoneId();
|
|
336
335
|
}
|
|
337
336
|
/** Get timestamp (milliseconds since midnight, January 1, 1970 UTC) of the current instance, not the true `Date`. */
|
|
338
337
|
get #timestamp() {
|
|
@@ -477,7 +476,7 @@ var Chronos = class Chronos {
|
|
|
477
476
|
}
|
|
478
477
|
/** @instance Gets the native `Date` instance of the current `Chronos`. */
|
|
479
478
|
toDate() {
|
|
480
|
-
const adjustmentMs = (
|
|
479
|
+
const adjustmentMs = (require_utils.extractMinutesFromUTC(this.#offset) - this.getUTCOffsetMinutes()) * 6e4;
|
|
481
480
|
return new Date(this.#timestamp - adjustmentMs);
|
|
482
481
|
}
|
|
483
482
|
/** @instance Returns a string representation of a date. */
|
|
@@ -1074,7 +1073,7 @@ var Chronos = class Chronos {
|
|
|
1074
1073
|
* @returns The timezone offset in minutes maintaining the current timezone regardless of system having different one.
|
|
1075
1074
|
*/
|
|
1076
1075
|
getTimeZoneOffsetMinutes() {
|
|
1077
|
-
return
|
|
1076
|
+
return require_utils.extractMinutesFromUTC(this.#offset);
|
|
1078
1077
|
}
|
|
1079
1078
|
/** @instance Returns new `Chronos` instance in UTC time */
|
|
1080
1079
|
toUTC() {
|
|
@@ -1372,7 +1371,7 @@ var Chronos = class Chronos {
|
|
|
1372
1371
|
*/
|
|
1373
1372
|
static isLeapYear(date) {
|
|
1374
1373
|
let year;
|
|
1375
|
-
if (
|
|
1374
|
+
if (require_convert_C8LsoKmI.isNumber(date)) if (date > 0 && date <= 9999) year = date;
|
|
1376
1375
|
else year = new Date(date).getFullYear();
|
|
1377
1376
|
else year = Chronos.#cast(date).year;
|
|
1378
1377
|
return require_guards.isLeapYear(year);
|
|
@@ -1427,7 +1426,7 @@ var Chronos = class Chronos {
|
|
|
1427
1426
|
static reconstruct(value) {
|
|
1428
1427
|
if (!require_helpers._hasChronosProperties(value)) throw new TypeError("Invalid input for reconstruction!");
|
|
1429
1428
|
const { native, origin, utcOffset, timeZoneName, timeZoneId, $tzTracker } = value;
|
|
1430
|
-
const offsetMins =
|
|
1429
|
+
const offsetMins = require_utils.extractMinutesFromUTC(utcOffset);
|
|
1431
1430
|
const chr = new Chronos(native);
|
|
1432
1431
|
const diffMins = chr.getTimeZoneOffsetMinutes() - offsetMins;
|
|
1433
1432
|
return (chr.utcOffset === utcOffset ? chr : chr.add(-diffMins, "minute")).#withOrigin(origin, utcOffset, timeZoneName, timeZoneId, $tzTracker);
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { D as INTERNALS } from "./seasons-
|
|
18
|
-
import { Ht as chronos, Vt as Chronos } from "./types-
|
|
17
|
+
import { D as INTERNALS } from "./seasons-DYk2jvtn.mjs";
|
|
18
|
+
import { Ht as chronos, Vt as Chronos } from "./types-CiFnGEL8.mjs";
|
|
19
19
|
export { Chronos, INTERNALS, chronos };
|
package/dist/index.mjs
CHANGED
|
@@ -15,13 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { c as MONTHS, o as DAYS, s as INTERNALS, u as MS_PER_DAY } from "./basic-DqKyujoj.mjs";
|
|
18
|
-
import {
|
|
19
|
-
import { t as isFunction } from "./non-primitives-CbAOB6lb.mjs";
|
|
18
|
+
import { h as isNumber, o as isFunction } from "./convert-C8LsoKmI-Blf3eLS6.mjs";
|
|
20
19
|
import { isDateString, isLeapYear } from "./guards.mjs";
|
|
21
|
-
import { c as _hasChronosProperties, n as _dateArgsToDate, p as _resolveNativeTzName, r as _formatDate, u as _normalizeOffset } from "./helpers-
|
|
22
|
-
import { l as getNativeTimeZoneId, r as extractMinutesFromUTC } from "./
|
|
20
|
+
import { c as _hasChronosProperties, n as _dateArgsToDate, p as _resolveNativeTzName, r as _formatDate, u as _normalizeOffset } from "./helpers-t49KkxOE.mjs";
|
|
21
|
+
import { l as getNativeTimeZoneId, r as extractMinutesFromUTC } from "./utils-DBy7S7hH.mjs";
|
|
23
22
|
|
|
24
|
-
//#region src/
|
|
23
|
+
//#region src/utilities/chronos-fn.ts
|
|
25
24
|
/**
|
|
26
25
|
* * Converts a date into a Chronos object and access to all `Chronos` methods and properties.
|
|
27
26
|
*
|