@bereasoftware/time-guard 2.6.1 → 2.7.1

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.
Files changed (98) hide show
  1. package/README.en.md +232 -0
  2. package/README.md +259 -4
  3. package/dist/angular/index.cjs +148 -0
  4. package/dist/angular/index.d.ts +2 -0
  5. package/dist/angular/index.es.js +143 -0
  6. package/dist/angular.d.ts +59 -0
  7. package/dist/calendars/index.cjs +357 -2
  8. package/dist/calendars/index.es.js +99 -68
  9. package/dist/chunk-BbtWAPZS.cjs +36 -0
  10. package/dist/core-BFdo248T.cjs +1892 -0
  11. package/dist/core-CyBR5PPd.js +1809 -0
  12. package/dist/core.d.ts +224 -0
  13. package/dist/index.d.ts +9 -0
  14. package/dist/locales/african.locale.d.ts +7 -0
  15. package/dist/locales/index.cjs +7 -1
  16. package/dist/{types/locales → locales}/index.d.ts +2 -2
  17. package/dist/locales/index.es.js +3 -3
  18. package/dist/locales/south-american.locale.d.ts +7 -0
  19. package/dist/locales-B1mDDyn_.cjs +3537 -0
  20. package/dist/{locales-DSBvgSaw.js → locales-By7IK3Ep.js} +749 -33
  21. package/dist/native/index.cjs +48 -0
  22. package/dist/native/index.d.ts +2 -0
  23. package/dist/native/index.es.js +18 -0
  24. package/dist/native.d.ts +9 -0
  25. package/dist/plugins/advanced-format.cjs +105 -2
  26. package/dist/plugins/advanced-format.es.js +63 -45
  27. package/dist/plugins/duration.cjs +258 -2
  28. package/dist/plugins/duration.es.js +165 -61
  29. package/dist/plugins/relative-time.cjs +166 -2
  30. package/dist/plugins/relative-time.es.js +74 -37
  31. package/dist/qwik/index.cjs +104 -0
  32. package/dist/qwik/index.d.ts +2 -0
  33. package/dist/qwik/index.es.js +100 -0
  34. package/dist/qwik.d.ts +32 -0
  35. package/dist/react/index.cjs +112 -0
  36. package/dist/react/index.d.ts +2 -0
  37. package/dist/react/index.es.js +103 -0
  38. package/dist/react.d.ts +46 -0
  39. package/dist/solid/index.cjs +127 -0
  40. package/dist/solid/index.d.ts +2 -0
  41. package/dist/solid/index.es.js +122 -0
  42. package/dist/solid.d.ts +53 -0
  43. package/dist/svelte/index.cjs +398 -0
  44. package/dist/svelte/index.d.ts +2 -0
  45. package/dist/svelte/index.es.js +393 -0
  46. package/dist/svelte.d.ts +88 -0
  47. package/dist/time-guard.cjs +7359 -4
  48. package/dist/time-guard.es.js +3625 -8085
  49. package/dist/time-guard.iife.js +13549 -4
  50. package/dist/time-guard.umd.js +13550 -4
  51. package/dist/types/index.d.ts +651 -127
  52. package/dist/vue/index.cjs +143 -0
  53. package/dist/vue/index.d.ts +2 -0
  54. package/dist/vue/index.es.js +137 -0
  55. package/dist/vue.d.ts +35 -0
  56. package/package.json +107 -27
  57. package/dist/calendars/index.cjs.map +0 -1
  58. package/dist/calendars/index.es.js.map +0 -1
  59. package/dist/locales-DSBvgSaw.js.map +0 -1
  60. package/dist/locales-ybx7jS8G.cjs +0 -2
  61. package/dist/locales-ybx7jS8G.cjs.map +0 -1
  62. package/dist/plugins/advanced-format.cjs.map +0 -1
  63. package/dist/plugins/advanced-format.es.js.map +0 -1
  64. package/dist/plugins/duration.cjs.map +0 -1
  65. package/dist/plugins/duration.es.js.map +0 -1
  66. package/dist/plugins/relative-time.cjs.map +0 -1
  67. package/dist/plugins/relative-time.es.js.map +0 -1
  68. package/dist/time-guard.cjs.map +0 -1
  69. package/dist/time-guard.es.js.map +0 -1
  70. package/dist/time-guard.iife.js.map +0 -1
  71. package/dist/time-guard.umd.js.map +0 -1
  72. package/dist/types/types/index.d.ts +0 -641
  73. /package/dist/{types/adapters → adapters}/temporal.adapter.d.ts +0 -0
  74. /package/dist/{types/calendars → calendars}/calendar.manager.d.ts +0 -0
  75. /package/dist/{types/calendars → calendars}/index.d.ts +0 -0
  76. /package/dist/{types/formatters → formatters}/date.formatter.d.ts +0 -0
  77. /package/dist/{types/locales → locales}/additional.locale.d.ts +0 -0
  78. /package/dist/{types/locales → locales}/asian.locale.d.ts +0 -0
  79. /package/dist/{types/locales → locales}/english.locale.d.ts +0 -0
  80. /package/dist/{types/locales → locales}/european.locale.d.ts +0 -0
  81. /package/dist/{types/locales → locales}/locale.manager.d.ts +0 -0
  82. /package/dist/{types/locales → locales}/middle-eastern.locale.d.ts +0 -0
  83. /package/dist/{types/locales → locales}/nordic.locale.d.ts +0 -0
  84. /package/dist/{types/locales → locales}/romance.locale.d.ts +0 -0
  85. /package/dist/{types/locales → locales}/slavic.locale.d.ts +0 -0
  86. /package/dist/{types/locales → locales}/spanish.locale.d.ts +0 -0
  87. /package/dist/{types/plugins → plugins}/advanced-format/index.d.ts +0 -0
  88. /package/dist/{types/plugins → plugins}/advanced-format.d.ts +0 -0
  89. /package/dist/{types/plugins → plugins}/duration/index.d.ts +0 -0
  90. /package/dist/{types/plugins → plugins}/duration/types.d.ts +0 -0
  91. /package/dist/{types/plugins → plugins}/duration.d.ts +0 -0
  92. /package/dist/{types/plugins → plugins}/index.d.ts +0 -0
  93. /package/dist/{types/plugins → plugins}/manager.d.ts +0 -0
  94. /package/dist/{types/plugins → plugins}/relative-time/index.d.ts +0 -0
  95. /package/dist/{types/plugins → plugins}/relative-time/types.d.ts +0 -0
  96. /package/dist/{types/plugins → plugins}/relative-time.d.ts +0 -0
  97. /package/dist/{types/time-guard.d.ts → time-guard.d.ts} +0 -0
  98. /package/dist/{types/utils → utils}/duration-locale.d.ts +0 -0
@@ -0,0 +1,48 @@
1
+ /*! time-guard v2.7.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const require_core = require("../core-BFdo248T.cjs");
4
+ const require_locales = require("../locales-B1mDDyn_.cjs");
5
+ const require_calendars_index = require("../calendars/index.cjs");
6
+ const require_plugins_relative_time = require("../plugins/relative-time.cjs");
7
+ const require_plugins_duration = require("../plugins/duration.cjs");
8
+ const require_plugins_advanced_format = require("../plugins/advanced-format.cjs");
9
+ //#region src/native.ts
10
+ /**
11
+ * TimeGuard - Modern date/time library using Temporal API
12
+ * Native Mode (zero-polyfill build)
13
+ * Assumes globalThis.Temporal is already available in the environment.
14
+ *
15
+ * @author Berea-Soft
16
+ * @license MIT
17
+ */
18
+ //#endregion
19
+ exports.ALL_LOCALES = require_locales.ALL_LOCALES;
20
+ exports.AdvancedFormatPlugin = require_plugins_advanced_format.AdvancedFormatPlugin;
21
+ exports.BuddhistCalendar = require_calendars_index.BuddhistCalendar;
22
+ exports.CalendarManager = require_core.CalendarManager;
23
+ exports.ChineseCalendar = require_calendars_index.ChineseCalendar;
24
+ exports.DateFormatter = require_core.DateFormatter;
25
+ exports.Duration = require_plugins_duration.Duration;
26
+ exports.DurationPlugin = require_plugins_duration.DurationPlugin;
27
+ exports.DurationResult = require_core.DurationResult;
28
+ exports.EN_LOCALE = require_core.EN_LOCALE;
29
+ exports.ES_LOCALE = require_core.ES_LOCALE;
30
+ exports.GregorianCalendar = require_core.GregorianCalendar;
31
+ exports.HebrewCalendar = require_calendars_index.HebrewCalendar;
32
+ exports.IslamicCalendar = require_calendars_index.IslamicCalendar;
33
+ exports.JapaneseCalendar = require_calendars_index.JapaneseCalendar;
34
+ exports.LOCALES_COUNT = require_locales.LOCALES_COUNT;
35
+ exports.LocaleManager = require_core.LocaleManager;
36
+ exports.PluginManager = require_core.PluginManager;
37
+ exports.RelativeTimePlugin = require_plugins_relative_time.RelativeTimePlugin;
38
+ exports.TemporalAdapter = require_core.TemporalAdapter;
39
+ exports.TimeGuard = require_core.TimeGuard;
40
+ exports.TimeRange = require_core.TimeRange;
41
+ exports.advancedFormatPlugin = require_plugins_advanced_format.default;
42
+ exports.calendarManager = require_core.calendarManager;
43
+ exports.durationPlugin = require_plugins_duration.default;
44
+ exports.getAvailableLocales = require_locales.getAvailableLocales;
45
+ exports.registerAllLocales = require_locales.registerAllLocales;
46
+ exports.relativeTimePlugin = require_plugins_relative_time.default;
47
+ exports.timeGuard = require_core.timeGuard;
48
+ exports.version = require_core.version;
@@ -0,0 +1,2 @@
1
+ export * from '../native'
2
+ export {}
@@ -0,0 +1,18 @@
1
+ /*! time-guard v2.7.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
+ import { a as version, c as GregorianCalendar, d as TemporalAdapter, f as EN_LOCALE, i as timeGuard, l as calendarManager, m as LocaleManager, n as TimeGuard, o as PluginManager, p as ES_LOCALE, r as TimeRange, s as CalendarManager, t as DurationResult, u as DateFormatter } from "../core-CyBR5PPd.js";
3
+ import { i as registerAllLocales, n as LOCALES_COUNT, r as getAvailableLocales, t as ALL_LOCALES } from "../locales-By7IK3Ep.js";
4
+ import { BuddhistCalendar, ChineseCalendar, HebrewCalendar, IslamicCalendar, JapaneseCalendar } from "../calendars/index.es.js";
5
+ import relative_time_default, { RelativeTimePlugin } from "../plugins/relative-time.es.js";
6
+ import durationPlugin, { Duration, DurationPlugin } from "../plugins/duration.es.js";
7
+ import advanced_format_default, { AdvancedFormatPlugin } from "../plugins/advanced-format.es.js";
8
+ //#region src/native.ts
9
+ /**
10
+ * TimeGuard - Modern date/time library using Temporal API
11
+ * Native Mode (zero-polyfill build)
12
+ * Assumes globalThis.Temporal is already available in the environment.
13
+ *
14
+ * @author Berea-Soft
15
+ * @license MIT
16
+ */
17
+ //#endregion
18
+ export { ALL_LOCALES, AdvancedFormatPlugin, BuddhistCalendar, CalendarManager, ChineseCalendar, DateFormatter, Duration, DurationPlugin, DurationResult, EN_LOCALE, ES_LOCALE, GregorianCalendar, HebrewCalendar, IslamicCalendar, JapaneseCalendar, LOCALES_COUNT, LocaleManager, PluginManager, RelativeTimePlugin, TemporalAdapter, TimeGuard, TimeRange, advanced_format_default as advancedFormatPlugin, calendarManager, durationPlugin, getAvailableLocales, registerAllLocales, relative_time_default as relativeTimePlugin, timeGuard, version };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * TimeGuard - Modern date/time library using Temporal API
3
+ * Native Mode (zero-polyfill build)
4
+ * Assumes globalThis.Temporal is already available in the environment.
5
+ *
6
+ * @author Berea-Soft
7
+ * @license MIT
8
+ */
9
+ export * from './core';
@@ -1,2 +1,105 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=class{name=`advanced-format`;version=`1.0.0`;install(e){let t=e.prototype.format;e.prototype.format=function(e){if(!e||typeof e!=`string`||!/Q|Do|w|W|gggg|GGGG|k{1,2}|X|x|zzz?/.test(e))return t.call(this,e);let n=this.toTemporal(),r=`toPlainDateTime`in n?n.toPlainDateTime():n,i=e=>{let t=[`th`,`st`,`nd`,`rd`],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])},a=(e,t)=>String(e).padStart(t,`0`),o=e=>{let t=new Date(e.year,0,4),n=new Date(t);n.setDate(t.getDate()-t.getDay()+(t.getDay()===0?-6:1));let r=new Date(e.year,e.month-1,e.day),i=Math.floor((r.getTime()-n.getTime())/(10080*60*1e3))+1;return Math.max(1,i)},s=e=>{let t=Math.ceil((e.day+new Date(e.year,e.month-1,1).getDay())/7);return Math.max(1,t)},c=e=>{let t=new Date(e.year,e.month-1,e.day),n=t.getTime()<new Date(e.year,0,1).getTime()?-1:+(t.getTime()>=new Date(e.year+1,0,1).getTime());return e.year+n},l=e=>{let t=e.month===1&&e.day<4?-1:+(e.month===12&&e.day>28);return e.year+t},u=e.replace(/Q|Do|w|W|gggg|GGGG|k{1,2}|X|x|zzz?/g,e=>{let t=``;switch(e){case`Q`:t=String(Math.ceil(r.month/3));break;case`Do`:t=i(r.day);break;case`W`:case`WW`:t=a(o(r),e===`W`?1:2);break;case`w`:case`ww`:t=a(s(r),e===`w`?1:2);break;case`GGGG`:t=String(c(r));break;case`gggg`:t=String(l(r));break;case`k`:case`kk`:t=a(r.hour===0?24:r.hour,e===`k`?1:2);break;case`X`:t=String(Math.floor(this.valueOf()/1e3));break;case`x`:t=String(this.valueOf());break;case`z`:t=`${this.getTimezoneOffset()}`;break;case`zzz`:t=`${this.getTimezoneOffsetLong()}`;break;default:return e}return`[${t}]`});return t.call(this,u)}}},t=new e;exports.AdvancedFormatPlugin=e,exports.default=t;
2
- //# sourceMappingURL=advanced-format.cjs.map
1
+ /*! time-guard v2.7.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ //#region src/plugins/advanced-format/index.ts
7
+ var AdvancedFormatPlugin = class {
8
+ name = "advanced-format";
9
+ version = "1.0.0";
10
+ /**
11
+ * Install plugin into TimeGuard
12
+ */
13
+ install(TimeGuardClass) {
14
+ const originalFormat = TimeGuardClass.prototype.format;
15
+ TimeGuardClass.prototype.format = function(pattern) {
16
+ if (!pattern || typeof pattern !== "string") return originalFormat.call(this, pattern);
17
+ if (!/Q|Do|w|W|gggg|GGGG|k{1,2}|X|x|zzz?/.test(pattern)) return originalFormat.call(this, pattern);
18
+ const temporal = this.toTemporal();
19
+ const temporal_dt = "toPlainDateTime" in temporal ? temporal.toPlainDateTime() : temporal;
20
+ const ordinalFn = (n) => {
21
+ const suffixes = [
22
+ "th",
23
+ "st",
24
+ "nd",
25
+ "rd"
26
+ ];
27
+ const v = n % 100;
28
+ return n + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
29
+ };
30
+ const padFn = (n, length) => String(n).padStart(length, "0");
31
+ const getISOWeek = (temporal) => {
32
+ const jan4 = new Date(temporal.year, 0, 4);
33
+ const week1Start = new Date(jan4);
34
+ week1Start.setDate(jan4.getDate() - jan4.getDay() + (jan4.getDay() === 0 ? -6 : 1));
35
+ const currentDate = new Date(temporal.year, temporal.month - 1, temporal.day);
36
+ const weekNum = Math.floor((currentDate.getTime() - week1Start.getTime()) / (10080 * 60 * 1e3)) + 1;
37
+ return Math.max(1, weekNum);
38
+ };
39
+ const getWeekOfYear = (temporal) => {
40
+ const weekNum = Math.ceil((temporal.day + new Date(temporal.year, temporal.month - 1, 1).getDay()) / 7);
41
+ return Math.max(1, weekNum);
42
+ };
43
+ const getISOWeekYear = (temporal) => {
44
+ const currentDate = new Date(temporal.year, temporal.month - 1, temporal.day);
45
+ const yearAdjust = currentDate.getTime() < new Date(temporal.year, 0, 1).getTime() ? -1 : currentDate.getTime() >= new Date(temporal.year + 1, 0, 1).getTime() ? 1 : 0;
46
+ return temporal.year + yearAdjust;
47
+ };
48
+ const getWeekYear = (temporal) => {
49
+ const yearAdjust = temporal.month === 1 && temporal.day < 4 ? -1 : temporal.month === 12 && temporal.day > 28 ? 1 : 0;
50
+ return temporal.year + yearAdjust;
51
+ };
52
+ const result = pattern.replace(/Q|Do|w|W|gggg|GGGG|k{1,2}|X|x|zzz?/g, (match) => {
53
+ let replacement = "";
54
+ switch (match) {
55
+ case "Q":
56
+ replacement = String(Math.ceil(temporal_dt.month / 3));
57
+ break;
58
+ case "Do":
59
+ replacement = ordinalFn(temporal_dt.day);
60
+ break;
61
+ case "W":
62
+ case "WW":
63
+ replacement = padFn(getISOWeek(temporal_dt), match === "W" ? 1 : 2);
64
+ break;
65
+ case "w":
66
+ case "ww":
67
+ replacement = padFn(getWeekOfYear(temporal_dt), match === "w" ? 1 : 2);
68
+ break;
69
+ case "GGGG":
70
+ replacement = String(getISOWeekYear(temporal_dt));
71
+ break;
72
+ case "gggg":
73
+ replacement = String(getWeekYear(temporal_dt));
74
+ break;
75
+ case "k":
76
+ case "kk":
77
+ replacement = padFn(temporal_dt.hour === 0 ? 24 : temporal_dt.hour, match === "k" ? 1 : 2);
78
+ break;
79
+ case "X":
80
+ replacement = String(Math.floor(this.valueOf() / 1e3));
81
+ break;
82
+ case "x":
83
+ replacement = String(this.valueOf());
84
+ break;
85
+ case "z":
86
+ replacement = `${this.getTimezoneOffset()}`;
87
+ break;
88
+ case "zzz":
89
+ replacement = `${this.getTimezoneOffsetLong()}`;
90
+ break;
91
+ default: return match;
92
+ }
93
+ return `[${replacement}]`;
94
+ });
95
+ return originalFormat.call(this, result);
96
+ };
97
+ }
98
+ };
99
+ /**
100
+ * Create and export default instance
101
+ */
102
+ var advanced_format_default = new AdvancedFormatPlugin();
103
+ //#endregion
104
+ exports.AdvancedFormatPlugin = AdvancedFormatPlugin;
105
+ exports.default = advanced_format_default;
@@ -1,82 +1,100 @@
1
- /*! time-guard v2.6.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
1
+ /*! time-guard v2.7.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
2
  //#region src/plugins/advanced-format/index.ts
3
- var e = class {
3
+ var AdvancedFormatPlugin = class {
4
4
  name = "advanced-format";
5
5
  version = "1.0.0";
6
- install(e) {
7
- let t = e.prototype.format;
8
- e.prototype.format = function(e) {
9
- if (!e || typeof e != "string" || !/Q|Do|w|W|gggg|GGGG|k{1,2}|X|x|zzz?/.test(e)) return t.call(this, e);
10
- let n = this.toTemporal(), r = "toPlainDateTime" in n ? n.toPlainDateTime() : n, i = (e) => {
11
- let t = [
6
+ /**
7
+ * Install plugin into TimeGuard
8
+ */
9
+ install(TimeGuardClass) {
10
+ const originalFormat = TimeGuardClass.prototype.format;
11
+ TimeGuardClass.prototype.format = function(pattern) {
12
+ if (!pattern || typeof pattern !== "string") return originalFormat.call(this, pattern);
13
+ if (!/Q|Do|w|W|gggg|GGGG|k{1,2}|X|x|zzz?/.test(pattern)) return originalFormat.call(this, pattern);
14
+ const temporal = this.toTemporal();
15
+ const temporal_dt = "toPlainDateTime" in temporal ? temporal.toPlainDateTime() : temporal;
16
+ const ordinalFn = (n) => {
17
+ const suffixes = [
12
18
  "th",
13
19
  "st",
14
20
  "nd",
15
21
  "rd"
16
- ], n = e % 100;
17
- return e + (t[(n - 20) % 10] || t[n] || t[0]);
18
- }, a = (e, t) => String(e).padStart(t, "0"), o = (e) => {
19
- let t = new Date(e.year, 0, 4), n = new Date(t);
20
- n.setDate(t.getDate() - t.getDay() + (t.getDay() === 0 ? -6 : 1));
21
- let r = new Date(e.year, e.month - 1, e.day), i = Math.floor((r.getTime() - n.getTime()) / (10080 * 60 * 1e3)) + 1;
22
- return Math.max(1, i);
23
- }, s = (e) => {
24
- let t = Math.ceil((e.day + new Date(e.year, e.month - 1, 1).getDay()) / 7);
25
- return Math.max(1, t);
26
- }, c = (e) => {
27
- let t = new Date(e.year, e.month - 1, e.day), n = t.getTime() < new Date(e.year, 0, 1).getTime() ? -1 : +(t.getTime() >= new Date(e.year + 1, 0, 1).getTime());
28
- return e.year + n;
29
- }, l = (e) => {
30
- let t = e.month === 1 && e.day < 4 ? -1 : +(e.month === 12 && e.day > 28);
31
- return e.year + t;
32
- }, u = e.replace(/Q|Do|w|W|gggg|GGGG|k{1,2}|X|x|zzz?/g, (e) => {
33
- let t = "";
34
- switch (e) {
22
+ ];
23
+ const v = n % 100;
24
+ return n + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
25
+ };
26
+ const padFn = (n, length) => String(n).padStart(length, "0");
27
+ const getISOWeek = (temporal) => {
28
+ const jan4 = new Date(temporal.year, 0, 4);
29
+ const week1Start = new Date(jan4);
30
+ week1Start.setDate(jan4.getDate() - jan4.getDay() + (jan4.getDay() === 0 ? -6 : 1));
31
+ const currentDate = new Date(temporal.year, temporal.month - 1, temporal.day);
32
+ const weekNum = Math.floor((currentDate.getTime() - week1Start.getTime()) / (10080 * 60 * 1e3)) + 1;
33
+ return Math.max(1, weekNum);
34
+ };
35
+ const getWeekOfYear = (temporal) => {
36
+ const weekNum = Math.ceil((temporal.day + new Date(temporal.year, temporal.month - 1, 1).getDay()) / 7);
37
+ return Math.max(1, weekNum);
38
+ };
39
+ const getISOWeekYear = (temporal) => {
40
+ const currentDate = new Date(temporal.year, temporal.month - 1, temporal.day);
41
+ const yearAdjust = currentDate.getTime() < new Date(temporal.year, 0, 1).getTime() ? -1 : currentDate.getTime() >= new Date(temporal.year + 1, 0, 1).getTime() ? 1 : 0;
42
+ return temporal.year + yearAdjust;
43
+ };
44
+ const getWeekYear = (temporal) => {
45
+ const yearAdjust = temporal.month === 1 && temporal.day < 4 ? -1 : temporal.month === 12 && temporal.day > 28 ? 1 : 0;
46
+ return temporal.year + yearAdjust;
47
+ };
48
+ const result = pattern.replace(/Q|Do|w|W|gggg|GGGG|k{1,2}|X|x|zzz?/g, (match) => {
49
+ let replacement = "";
50
+ switch (match) {
35
51
  case "Q":
36
- t = String(Math.ceil(r.month / 3));
52
+ replacement = String(Math.ceil(temporal_dt.month / 3));
37
53
  break;
38
54
  case "Do":
39
- t = i(r.day);
55
+ replacement = ordinalFn(temporal_dt.day);
40
56
  break;
41
57
  case "W":
42
58
  case "WW":
43
- t = a(o(r), e === "W" ? 1 : 2);
59
+ replacement = padFn(getISOWeek(temporal_dt), match === "W" ? 1 : 2);
44
60
  break;
45
61
  case "w":
46
62
  case "ww":
47
- t = a(s(r), e === "w" ? 1 : 2);
63
+ replacement = padFn(getWeekOfYear(temporal_dt), match === "w" ? 1 : 2);
48
64
  break;
49
65
  case "GGGG":
50
- t = String(c(r));
66
+ replacement = String(getISOWeekYear(temporal_dt));
51
67
  break;
52
68
  case "gggg":
53
- t = String(l(r));
69
+ replacement = String(getWeekYear(temporal_dt));
54
70
  break;
55
71
  case "k":
56
72
  case "kk":
57
- t = a(r.hour === 0 ? 24 : r.hour, e === "k" ? 1 : 2);
73
+ replacement = padFn(temporal_dt.hour === 0 ? 24 : temporal_dt.hour, match === "k" ? 1 : 2);
58
74
  break;
59
75
  case "X":
60
- t = String(Math.floor(this.valueOf() / 1e3));
76
+ replacement = String(Math.floor(this.valueOf() / 1e3));
61
77
  break;
62
78
  case "x":
63
- t = String(this.valueOf());
79
+ replacement = String(this.valueOf());
64
80
  break;
65
81
  case "z":
66
- t = `${this.getTimezoneOffset()}`;
82
+ replacement = `${this.getTimezoneOffset()}`;
67
83
  break;
68
84
  case "zzz":
69
- t = `${this.getTimezoneOffsetLong()}`;
85
+ replacement = `${this.getTimezoneOffsetLong()}`;
70
86
  break;
71
- default: return e;
87
+ default: return match;
72
88
  }
73
- return `[${t}]`;
89
+ return `[${replacement}]`;
74
90
  });
75
- return t.call(this, u);
91
+ return originalFormat.call(this, result);
76
92
  };
77
93
  }
78
- }, t = new e();
94
+ };
95
+ /**
96
+ * Create and export default instance
97
+ */
98
+ var advanced_format_default = new AdvancedFormatPlugin();
79
99
  //#endregion
80
- export { e as AdvancedFormatPlugin, t as default };
81
-
82
- //# sourceMappingURL=advanced-format.es.js.map
100
+ export { AdvancedFormatPlugin, advanced_format_default as default };
@@ -1,2 +1,258 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=class e{years=0;months=0;weeks=0;days=0;hours=0;minutes=0;seconds=0;milliseconds=0;constructor(e){this.years=e.years||0,this.months=e.months||0,this.weeks=e.weeks||0,this.days=e.days||0,this.hours=e.hours||0,this.minutes=e.minutes||0,this.seconds=e.seconds||0,this.milliseconds=e.milliseconds||0}static fromISO(t){let n=t.match(/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?)?$/);if(!n)throw Error(`Invalid ISO 8601 duration: ${t}`);let[,r,i,a,,o,s,c,l]=n,u=r?-1:1;return new e({years:parseInt(i||`0`,10)*u,months:parseInt(a||`0`,10)*u,days:parseInt(o||`0`,10)*u,hours:parseInt(s||`0`,10)*u,minutes:parseInt(c||`0`,10)*u,seconds:parseFloat(l||`0`)*u})}static between(t,n){let r=t.toTemporal(),i=n.toTemporal().since(r);return new e({years:i.years||0,months:i.months||0,weeks:0,days:i.days||0,hours:i.hours||0,minutes:i.minutes||0,seconds:i.seconds||0,milliseconds:i.milliseconds||0})}static fromMilliseconds(t){let n=t<0,r=Math.abs(t),i=Math.floor(r/(1e3*60*60*24*365)),a=Math.floor(r%(1e3*60*60*24*365)/(1e3*60*60*24*30)),o=Math.floor(r%(1e3*60*60*24*30)/(1e3*60*60*24)),s=Math.floor(r%(1e3*60*60*24)/(1e3*60*60)),c=Math.floor(r%(1e3*60*60)/(1e3*60)),l=Math.floor(r%(1e3*60)/1e3),u=Math.floor(r%1e3),d=n?-1:1;return new e({years:i*d,months:a*d,days:o*d,hours:s*d,minutes:c*d,seconds:l*d,milliseconds:u*d})}as(e){return this.asMilliseconds()/{milliseconds:1,seconds:1e3,minutes:1e3*60,hours:1e3*60*60,days:1e3*60*60*24,weeks:1e3*60*60*24*7,months:1e3*60*60*24*30,years:1e3*60*60*24*365}[e]}asMilliseconds(){return this.years*1e3*60*60*24*365+this.months*1e3*60*60*24*30+this.weeks*1e3*60*60*24*7+this.days*1e3*60*60*24+this.hours*1e3*60*60+this.minutes*1e3*60+this.seconds*1e3+this.milliseconds}asSeconds(){return this.asMilliseconds()/1e3}asMinutes(){return this.asSeconds()/60}asHours(){return this.asMinutes()/60}asDays(){return this.asHours()/24}asWeeks(){return this.asDays()/7}asMonths(){return this.asDays()/30}asYears(){return this.asDays()/365}toObject(){return{years:this.years,months:this.months,weeks:this.weeks,days:this.days,hours:this.hours,minutes:this.minutes,seconds:this.seconds,milliseconds:this.milliseconds}}toISO(){let e=``;this.years&&(e+=`${this.years}Y`),this.months&&(e+=`${this.months}M`),(this.weeks||this.days)&&(e+=`${this.weeks*7+this.days}D`);let t=``;return this.hours&&(t+=`${this.hours}H`),this.minutes&&(t+=`${this.minutes}M`),(this.seconds||this.milliseconds)&&(t+=`${this.seconds+this.milliseconds/1e3}S`),`${this.isNegative()?`-`:``}P${e}${t?`T${t}`:``}`}humanize(){let e=[];if(this.years&&e.push(`${Math.abs(this.years)} year${Math.abs(this.years)===1?``:`s`}`),this.months&&e.push(`${Math.abs(this.months)} month${Math.abs(this.months)===1?``:`s`}`),this.weeks&&e.push(`${Math.abs(this.weeks)} week${Math.abs(this.weeks)===1?``:`s`}`),this.days&&e.push(`${Math.abs(this.days)} day${Math.abs(this.days)===1?``:`s`}`),this.hours&&e.push(`${Math.abs(this.hours)} hour${Math.abs(this.hours)===1?``:`s`}`),this.minutes&&e.push(`${Math.abs(this.minutes)} minute${Math.abs(this.minutes)===1?``:`s`}`),this.seconds&&e.push(`${Math.abs(this.seconds)} second${Math.abs(this.seconds)===1?``:`s`}`),this.milliseconds&&e.push(`${Math.abs(this.milliseconds)} ms`),e.length===0)return`0 seconds`;let t=e.join(`, `);return this.isNegative()?`-${t}`:t}isNegative(){return this.years<0||this.months<0||this.weeks<0||this.days<0||this.hours<0||this.minutes<0||this.seconds<0||this.milliseconds<0}abs(){return new e({years:Math.abs(this.years),months:Math.abs(this.months),weeks:Math.abs(this.weeks),days:Math.abs(this.days),hours:Math.abs(this.hours),minutes:Math.abs(this.minutes),seconds:Math.abs(this.seconds),milliseconds:Math.abs(this.milliseconds)})}toString(){return this.toISO()}},t=class{name=`duration`;version=`1.0.0`;install(t){t.prototype.duration=function(t){return e.between(this,t)},t.Duration=e,t.duration={fromISO:t=>e.fromISO(t),between:(t,n)=>e.between(t,n),fromMilliseconds:t=>e.fromMilliseconds(t)}}},n=new t;exports.Duration=e,exports.DurationPlugin=t,exports.default=n,exports.durationPlugin=n;
2
- //# sourceMappingURL=duration.cjs.map
1
+ /*! time-guard v2.7.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ //#region src/plugins/duration/index.ts
7
+ /**
8
+ * Duration class - represents time span following ISO 8601 standard
9
+ */
10
+ var Duration = class Duration {
11
+ years = 0;
12
+ months = 0;
13
+ weeks = 0;
14
+ days = 0;
15
+ hours = 0;
16
+ minutes = 0;
17
+ seconds = 0;
18
+ milliseconds = 0;
19
+ constructor(input) {
20
+ this.years = input.years || 0;
21
+ this.months = input.months || 0;
22
+ this.weeks = input.weeks || 0;
23
+ this.days = input.days || 0;
24
+ this.hours = input.hours || 0;
25
+ this.minutes = input.minutes || 0;
26
+ this.seconds = input.seconds || 0;
27
+ this.milliseconds = input.milliseconds || 0;
28
+ }
29
+ /**
30
+ * Create Duration from ISO 8601 string
31
+ * @example Duration.fromISO("P3Y6M4DT12H30M5S")
32
+ */
33
+ static fromISO(iso) {
34
+ const match = iso.match(/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?)?$/);
35
+ if (!match) throw new Error(`Invalid ISO 8601 duration: ${iso}`);
36
+ const [, negative, years, months, , days, hours, minutes, seconds] = match;
37
+ const multiplier = negative ? -1 : 1;
38
+ return new Duration({
39
+ years: parseInt(years || "0", 10) * multiplier,
40
+ months: parseInt(months || "0", 10) * multiplier,
41
+ days: parseInt(days || "0", 10) * multiplier,
42
+ hours: parseInt(hours || "0", 10) * multiplier,
43
+ minutes: parseInt(minutes || "0", 10) * multiplier,
44
+ seconds: parseFloat(seconds || "0") * multiplier
45
+ });
46
+ }
47
+ /**
48
+ * Create a Duration between this date and another
49
+ */
50
+ static between(from, to) {
51
+ const fromDT = from.toTemporal();
52
+ const duration = to.toTemporal().since(fromDT);
53
+ return new Duration({
54
+ years: duration.years || 0,
55
+ months: duration.months || 0,
56
+ weeks: 0,
57
+ days: duration.days || 0,
58
+ hours: duration.hours || 0,
59
+ minutes: duration.minutes || 0,
60
+ seconds: duration.seconds || 0,
61
+ milliseconds: duration.milliseconds || 0
62
+ });
63
+ }
64
+ /**
65
+ * Create Duration from milliseconds
66
+ */
67
+ static fromMilliseconds(ms) {
68
+ const isNegative = ms < 0;
69
+ const absMilhs = Math.abs(ms);
70
+ const years = Math.floor(absMilhs / (1e3 * 60 * 60 * 24 * 365));
71
+ const months = Math.floor(absMilhs % (1e3 * 60 * 60 * 24 * 365) / (1e3 * 60 * 60 * 24 * 30));
72
+ const days = Math.floor(absMilhs % (1e3 * 60 * 60 * 24 * 30) / (1e3 * 60 * 60 * 24));
73
+ const hours = Math.floor(absMilhs % (1e3 * 60 * 60 * 24) / (1e3 * 60 * 60));
74
+ const minutes = Math.floor(absMilhs % (1e3 * 60 * 60) / (1e3 * 60));
75
+ const seconds = Math.floor(absMilhs % (1e3 * 60) / 1e3);
76
+ const milliseconds = Math.floor(absMilhs % 1e3);
77
+ const multiplier = isNegative ? -1 : 1;
78
+ return new Duration({
79
+ years: years * multiplier,
80
+ months: months * multiplier,
81
+ days: days * multiplier,
82
+ hours: hours * multiplier,
83
+ minutes: minutes * multiplier,
84
+ seconds: seconds * multiplier,
85
+ milliseconds: milliseconds * multiplier
86
+ });
87
+ }
88
+ /**
89
+ * Get duration in specific unit
90
+ */
91
+ as(unit) {
92
+ return this.asMilliseconds() / {
93
+ milliseconds: 1,
94
+ seconds: 1e3,
95
+ minutes: 1e3 * 60,
96
+ hours: 1e3 * 60 * 60,
97
+ days: 1e3 * 60 * 60 * 24,
98
+ weeks: 1e3 * 60 * 60 * 24 * 7,
99
+ months: 1e3 * 60 * 60 * 24 * 30,
100
+ years: 1e3 * 60 * 60 * 24 * 365
101
+ }[unit];
102
+ }
103
+ /**
104
+ * Get duration as milliseconds
105
+ */
106
+ asMilliseconds() {
107
+ return this.years * 1e3 * 60 * 60 * 24 * 365 + this.months * 1e3 * 60 * 60 * 24 * 30 + this.weeks * 1e3 * 60 * 60 * 24 * 7 + this.days * 1e3 * 60 * 60 * 24 + this.hours * 1e3 * 60 * 60 + this.minutes * 1e3 * 60 + this.seconds * 1e3 + this.milliseconds;
108
+ }
109
+ /**
110
+ * Get duration as seconds
111
+ */
112
+ asSeconds() {
113
+ return this.asMilliseconds() / 1e3;
114
+ }
115
+ /**
116
+ * Get duration as minutes
117
+ */
118
+ asMinutes() {
119
+ return this.asSeconds() / 60;
120
+ }
121
+ /**
122
+ * Get duration as hours
123
+ */
124
+ asHours() {
125
+ return this.asMinutes() / 60;
126
+ }
127
+ /**
128
+ * Get duration as days
129
+ */
130
+ asDays() {
131
+ return this.asHours() / 24;
132
+ }
133
+ /**
134
+ * Get duration as weeks
135
+ */
136
+ asWeeks() {
137
+ return this.asDays() / 7;
138
+ }
139
+ /**
140
+ * Get duration as months
141
+ */
142
+ asMonths() {
143
+ return this.asDays() / 30;
144
+ }
145
+ /**
146
+ * Get duration as years
147
+ */
148
+ asYears() {
149
+ return this.asDays() / 365;
150
+ }
151
+ /**
152
+ * Get all components
153
+ */
154
+ toObject() {
155
+ return {
156
+ years: this.years,
157
+ months: this.months,
158
+ weeks: this.weeks,
159
+ days: this.days,
160
+ hours: this.hours,
161
+ minutes: this.minutes,
162
+ seconds: this.seconds,
163
+ milliseconds: this.milliseconds
164
+ };
165
+ }
166
+ /**
167
+ * Get ISO 8601 string representation
168
+ * @example "P3Y6M4DT12H30M5S"
169
+ */
170
+ toISO() {
171
+ let datePart = "";
172
+ if (this.years) datePart += `${this.years}Y`;
173
+ if (this.months) datePart += `${this.months}M`;
174
+ if (this.weeks || this.days) datePart += `${this.weeks * 7 + this.days}D`;
175
+ let timePart = "";
176
+ if (this.hours) timePart += `${this.hours}H`;
177
+ if (this.minutes) timePart += `${this.minutes}M`;
178
+ if (this.seconds || this.milliseconds) timePart += `${this.seconds + this.milliseconds / 1e3}S`;
179
+ return `${this.isNegative() ? "-" : ""}P${datePart}${timePart ? `T${timePart}` : ""}`;
180
+ }
181
+ /**
182
+ * Get human-readable string
183
+ */
184
+ humanize() {
185
+ const parts = [];
186
+ if (this.years) parts.push(`${Math.abs(this.years)} year${Math.abs(this.years) !== 1 ? "s" : ""}`);
187
+ if (this.months) parts.push(`${Math.abs(this.months)} month${Math.abs(this.months) !== 1 ? "s" : ""}`);
188
+ if (this.weeks) parts.push(`${Math.abs(this.weeks)} week${Math.abs(this.weeks) !== 1 ? "s" : ""}`);
189
+ if (this.days) parts.push(`${Math.abs(this.days)} day${Math.abs(this.days) !== 1 ? "s" : ""}`);
190
+ if (this.hours) parts.push(`${Math.abs(this.hours)} hour${Math.abs(this.hours) !== 1 ? "s" : ""}`);
191
+ if (this.minutes) parts.push(`${Math.abs(this.minutes)} minute${Math.abs(this.minutes) !== 1 ? "s" : ""}`);
192
+ if (this.seconds) parts.push(`${Math.abs(this.seconds)} second${Math.abs(this.seconds) !== 1 ? "s" : ""}`);
193
+ if (this.milliseconds) parts.push(`${Math.abs(this.milliseconds)} ms`);
194
+ if (parts.length === 0) return "0 seconds";
195
+ const text = parts.join(", ");
196
+ return this.isNegative() ? `-${text}` : text;
197
+ }
198
+ /**
199
+ * Check if duration is negative
200
+ */
201
+ isNegative() {
202
+ return this.years < 0 || this.months < 0 || this.weeks < 0 || this.days < 0 || this.hours < 0 || this.minutes < 0 || this.seconds < 0 || this.milliseconds < 0;
203
+ }
204
+ /**
205
+ * Get absolute duration
206
+ */
207
+ abs() {
208
+ return new Duration({
209
+ years: Math.abs(this.years),
210
+ months: Math.abs(this.months),
211
+ weeks: Math.abs(this.weeks),
212
+ days: Math.abs(this.days),
213
+ hours: Math.abs(this.hours),
214
+ minutes: Math.abs(this.minutes),
215
+ seconds: Math.abs(this.seconds),
216
+ milliseconds: Math.abs(this.milliseconds)
217
+ });
218
+ }
219
+ /**
220
+ * String representation
221
+ */
222
+ toString() {
223
+ return this.toISO();
224
+ }
225
+ };
226
+ /**
227
+ * Duration Plugin
228
+ */
229
+ var DurationPlugin = class {
230
+ name = "duration";
231
+ version = "1.0.0";
232
+ /**
233
+ * Install plugin into TimeGuard
234
+ */
235
+ install(TimeGuardClass) {
236
+ /**
237
+ * Create a Duration between this date and another
238
+ */
239
+ TimeGuardClass.prototype.duration = function(other) {
240
+ return Duration.between(this, other);
241
+ };
242
+ TimeGuardClass.Duration = Duration;
243
+ TimeGuardClass.duration = {
244
+ fromISO: (iso) => Duration.fromISO(iso),
245
+ between: (from, to) => Duration.between(from, to),
246
+ fromMilliseconds: (ms) => Duration.fromMilliseconds(ms)
247
+ };
248
+ }
249
+ };
250
+ /**
251
+ * Create and export default instance
252
+ */
253
+ var durationPlugin = new DurationPlugin();
254
+ //#endregion
255
+ exports.Duration = Duration;
256
+ exports.DurationPlugin = DurationPlugin;
257
+ exports.default = durationPlugin;
258
+ exports.durationPlugin = durationPlugin;