@bereasoftware/time-guard 2.6.0 → 2.7.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/README.en.md +232 -0
- package/README.md +259 -4
- package/dist/{types/adapters → adapters}/temporal.adapter.d.ts +4 -9
- package/dist/angular/index.cjs +148 -0
- package/dist/angular/index.d.ts +2 -0
- package/dist/angular/index.es.js +143 -0
- package/dist/angular.d.ts +59 -0
- package/dist/calendars/index.cjs +357 -2
- package/dist/calendars/index.es.js +99 -68
- package/dist/chunk-Ddh6569R.cjs +36 -0
- package/dist/core-BAd7GYfw.js +1809 -0
- package/dist/core-CafqOI7W.cjs +1892 -0
- package/dist/core.d.ts +224 -0
- package/dist/index.d.ts +9 -0
- package/dist/locales/african.locale.d.ts +7 -0
- package/dist/locales/index.cjs +7 -2
- package/dist/{types/locales → locales}/index.d.ts +2 -2
- package/dist/locales/index.es.js +3 -2797
- package/dist/locales/south-american.locale.d.ts +7 -0
- package/dist/locales-C2-lOmC8.cjs +3537 -0
- package/dist/locales-CcuSu4P1.js +3514 -0
- package/dist/native/index.cjs +48 -0
- package/dist/native/index.d.ts +2 -0
- package/dist/native/index.es.js +18 -0
- package/dist/native.d.ts +9 -0
- package/dist/plugins/advanced-format.cjs +105 -2
- package/dist/plugins/advanced-format.es.js +63 -45
- package/dist/plugins/duration.cjs +258 -2
- package/dist/plugins/duration.es.js +165 -61
- package/dist/plugins/index.d.ts +10 -0
- package/dist/plugins/relative-time.cjs +166 -2
- package/dist/plugins/relative-time.es.js +74 -37
- package/dist/qwik/index.cjs +104 -0
- package/dist/qwik/index.d.ts +2 -0
- package/dist/qwik/index.es.js +100 -0
- package/dist/qwik.d.ts +32 -0
- package/dist/react/index.cjs +112 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.es.js +103 -0
- package/dist/react.d.ts +46 -0
- package/dist/solid/index.cjs +127 -0
- package/dist/solid/index.d.ts +2 -0
- package/dist/solid/index.es.js +122 -0
- package/dist/solid.d.ts +53 -0
- package/dist/svelte/index.cjs +398 -0
- package/dist/svelte/index.d.ts +2 -0
- package/dist/svelte/index.es.js +393 -0
- package/dist/svelte.d.ts +88 -0
- package/dist/time-guard.cjs +7359 -4
- package/dist/time-guard.d.ts +2 -0
- package/dist/time-guard.es.js +3625 -8073
- package/dist/time-guard.iife.js +13549 -4
- package/dist/time-guard.umd.js +13550 -4
- package/dist/types/index.d.ts +651 -128
- package/dist/vue/index.cjs +143 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.es.js +137 -0
- package/dist/vue.d.ts +35 -0
- package/package.json +111 -17
- package/dist/calendars/index.cjs.map +0 -1
- package/dist/calendars/index.es.js.map +0 -1
- package/dist/locales/index.cjs.map +0 -1
- package/dist/locales/index.es.js.map +0 -1
- package/dist/plugins/advanced-format.cjs.map +0 -1
- package/dist/plugins/advanced-format.es.js.map +0 -1
- package/dist/plugins/duration.cjs.map +0 -1
- package/dist/plugins/duration.es.js.map +0 -1
- package/dist/plugins/relative-time.cjs.map +0 -1
- package/dist/plugins/relative-time.es.js.map +0 -1
- package/dist/time-guard.cjs.map +0 -1
- package/dist/time-guard.es.js.map +0 -1
- package/dist/time-guard.iife.js.map +0 -1
- package/dist/time-guard.umd.js.map +0 -1
- package/dist/types/plugins/index.d.ts +0 -10
- package/dist/types/types/index.d.ts +0 -586
- /package/dist/{types/calendars → calendars}/calendar.manager.d.ts +0 -0
- /package/dist/{types/calendars → calendars}/index.d.ts +0 -0
- /package/dist/{types/formatters → formatters}/date.formatter.d.ts +0 -0
- /package/dist/{types/locales → locales}/additional.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/asian.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/english.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/european.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/locale.manager.d.ts +0 -0
- /package/dist/{types/locales → locales}/middle-eastern.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/nordic.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/romance.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/slavic.locale.d.ts +0 -0
- /package/dist/{types/locales → locales}/spanish.locale.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/advanced-format/index.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/advanced-format.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/duration/index.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/duration/types.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/duration.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/manager.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/relative-time/index.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/relative-time/types.d.ts +0 -0
- /package/dist/{types/plugins → plugins}/relative-time.d.ts +0 -0
- /package/dist/{types/utils → utils}/duration-locale.d.ts +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/*! time-guard v2.7.0 | (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-CafqOI7W.cjs");
|
|
4
|
+
let vue = require("vue");
|
|
5
|
+
//#region src/vue.ts
|
|
6
|
+
/**
|
|
7
|
+
* Unique symbol key for injecting TimeGuard global configuration.
|
|
8
|
+
*/
|
|
9
|
+
var TimeGuardConfigKey = Symbol("TimeGuardConfig");
|
|
10
|
+
/**
|
|
11
|
+
* Vue Directive for dynamically and reactively formatting dates.
|
|
12
|
+
* Usage:
|
|
13
|
+
* - `<span v-time-guard:format="date" data-pattern="YYYY-MM-DD"></span>`
|
|
14
|
+
* - `<span v-time-guard:relative="date" data-locale="es"></span>`
|
|
15
|
+
*/
|
|
16
|
+
/** Internal WeakMap to track interval timers per element (avoids `any` casts). */
|
|
17
|
+
var directiveTimerMap = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
var vTimeGuard = {
|
|
19
|
+
mounted(el, binding) {
|
|
20
|
+
updateDirective(el, binding);
|
|
21
|
+
},
|
|
22
|
+
updated(el, binding) {
|
|
23
|
+
updateDirective(el, binding);
|
|
24
|
+
},
|
|
25
|
+
unmounted(el) {
|
|
26
|
+
const timer = directiveTimerMap.get(el);
|
|
27
|
+
if (timer) {
|
|
28
|
+
clearInterval(timer);
|
|
29
|
+
directiveTimerMap.delete(el);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function updateDirective(el, binding) {
|
|
34
|
+
const existingTimer = directiveTimerMap.get(el);
|
|
35
|
+
if (existingTimer) {
|
|
36
|
+
clearInterval(existingTimer);
|
|
37
|
+
directiveTimerMap.delete(el);
|
|
38
|
+
}
|
|
39
|
+
const value = binding.value;
|
|
40
|
+
if (value === void 0 || value === null) {
|
|
41
|
+
el.textContent = "";
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const mode = binding.arg || "format";
|
|
45
|
+
const pattern = el.getAttribute("data-pattern") || "YYYY-MM-DD HH:mm:ss";
|
|
46
|
+
const locale = el.getAttribute("data-locale") || void 0;
|
|
47
|
+
const intervalMs = parseInt(el.getAttribute("data-interval") || "60000", 10);
|
|
48
|
+
const numeric = el.getAttribute("data-numeric") || void 0;
|
|
49
|
+
const render = () => {
|
|
50
|
+
try {
|
|
51
|
+
const tg = require_core.TimeGuard.from(value);
|
|
52
|
+
if (mode === "relative") {
|
|
53
|
+
const now = require_core.TimeGuard.now();
|
|
54
|
+
el.textContent = tg.since(now).humanize({
|
|
55
|
+
locale,
|
|
56
|
+
numeric
|
|
57
|
+
});
|
|
58
|
+
} else el.textContent = locale ? tg.locale(locale).format(pattern) : tg.format(pattern);
|
|
59
|
+
} catch {
|
|
60
|
+
el.textContent = String(value);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
render();
|
|
64
|
+
if (mode === "relative" || el.getAttribute("data-live") === "true") directiveTimerMap.set(el, setInterval(render, intervalMs));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Vue Plugin to register a global TimeGuard configuration and register v-time-guard directive.
|
|
68
|
+
*/
|
|
69
|
+
var TimeGuardVuePlugin = { install(app, options) {
|
|
70
|
+
app.provide(TimeGuardConfigKey, options);
|
|
71
|
+
app.directive("time-guard", vTimeGuard);
|
|
72
|
+
} };
|
|
73
|
+
/**
|
|
74
|
+
* Vue Composable to create a reactive Ref of a TimeGuard instance.
|
|
75
|
+
* Automatically updates when input or configuration changes.
|
|
76
|
+
* Inherits global injected configuration as fallback.
|
|
77
|
+
*/
|
|
78
|
+
function useTimeGuard(input, config) {
|
|
79
|
+
const globalConfig = (0, vue.inject)(TimeGuardConfigKey, void 0);
|
|
80
|
+
const activeConfig = config ?? globalConfig;
|
|
81
|
+
const tg = (0, vue.ref)(require_core.TimeGuard.from(input, activeConfig));
|
|
82
|
+
(0, vue.watch)([() => input, () => activeConfig ? JSON.stringify(activeConfig) : void 0], () => {
|
|
83
|
+
tg.value = require_core.TimeGuard.from(input, activeConfig);
|
|
84
|
+
}, { deep: true });
|
|
85
|
+
return tg;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Vue Composable to get a reactive TimeGuard Ref representing the current time.
|
|
89
|
+
* Automatically updates on a specified interval (default: 1000ms).
|
|
90
|
+
* Inherits global injected configuration as fallback.
|
|
91
|
+
*/
|
|
92
|
+
function useCurrentTime(options) {
|
|
93
|
+
const globalConfig = (0, vue.inject)(TimeGuardConfigKey, void 0);
|
|
94
|
+
const activeConfig = options?.config ?? globalConfig;
|
|
95
|
+
const interval = options?.interval ?? 1e3;
|
|
96
|
+
const time = (0, vue.ref)(require_core.TimeGuard.now(activeConfig));
|
|
97
|
+
const timer = setInterval(() => {
|
|
98
|
+
time.value = require_core.TimeGuard.now(activeConfig);
|
|
99
|
+
}, interval);
|
|
100
|
+
(0, vue.onUnmounted)(() => {
|
|
101
|
+
clearInterval(timer);
|
|
102
|
+
});
|
|
103
|
+
return time;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Vue Composable that returns a reactive relative time Ref updating periodically.
|
|
107
|
+
* Inherits global injected configuration as fallback.
|
|
108
|
+
*/
|
|
109
|
+
function useRelativeTime(date, options) {
|
|
110
|
+
const globalConfig = (0, vue.inject)(TimeGuardConfigKey, void 0);
|
|
111
|
+
const interval = options?.interval ?? 6e4;
|
|
112
|
+
const locale = options?.locale ?? globalConfig?.locale;
|
|
113
|
+
const numeric = options?.numeric;
|
|
114
|
+
const relative = (0, vue.ref)("");
|
|
115
|
+
const update = () => {
|
|
116
|
+
const tgDate = require_core.TimeGuard.from(date);
|
|
117
|
+
const now = require_core.TimeGuard.now();
|
|
118
|
+
relative.value = tgDate.since(now).humanize({
|
|
119
|
+
locale,
|
|
120
|
+
numeric
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
update();
|
|
124
|
+
const timer = setInterval(update, interval);
|
|
125
|
+
(0, vue.watch)([
|
|
126
|
+
() => date,
|
|
127
|
+
() => locale,
|
|
128
|
+
() => numeric
|
|
129
|
+
], () => {
|
|
130
|
+
update();
|
|
131
|
+
}, { deep: true });
|
|
132
|
+
(0, vue.onUnmounted)(() => {
|
|
133
|
+
clearInterval(timer);
|
|
134
|
+
});
|
|
135
|
+
return relative;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
exports.TimeGuardConfigKey = TimeGuardConfigKey;
|
|
139
|
+
exports.TimeGuardVuePlugin = TimeGuardVuePlugin;
|
|
140
|
+
exports.useCurrentTime = useCurrentTime;
|
|
141
|
+
exports.useRelativeTime = useRelativeTime;
|
|
142
|
+
exports.useTimeGuard = useTimeGuard;
|
|
143
|
+
exports.vTimeGuard = vTimeGuard;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*! time-guard v2.7.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
|
|
2
|
+
import { n as TimeGuard } from "../core-BAd7GYfw.js";
|
|
3
|
+
import { inject, onUnmounted, ref, watch } from "vue";
|
|
4
|
+
//#region src/vue.ts
|
|
5
|
+
/**
|
|
6
|
+
* Unique symbol key for injecting TimeGuard global configuration.
|
|
7
|
+
*/
|
|
8
|
+
var TimeGuardConfigKey = Symbol("TimeGuardConfig");
|
|
9
|
+
/**
|
|
10
|
+
* Vue Directive for dynamically and reactively formatting dates.
|
|
11
|
+
* Usage:
|
|
12
|
+
* - `<span v-time-guard:format="date" data-pattern="YYYY-MM-DD"></span>`
|
|
13
|
+
* - `<span v-time-guard:relative="date" data-locale="es"></span>`
|
|
14
|
+
*/
|
|
15
|
+
/** Internal WeakMap to track interval timers per element (avoids `any` casts). */
|
|
16
|
+
var directiveTimerMap = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
var vTimeGuard = {
|
|
18
|
+
mounted(el, binding) {
|
|
19
|
+
updateDirective(el, binding);
|
|
20
|
+
},
|
|
21
|
+
updated(el, binding) {
|
|
22
|
+
updateDirective(el, binding);
|
|
23
|
+
},
|
|
24
|
+
unmounted(el) {
|
|
25
|
+
const timer = directiveTimerMap.get(el);
|
|
26
|
+
if (timer) {
|
|
27
|
+
clearInterval(timer);
|
|
28
|
+
directiveTimerMap.delete(el);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function updateDirective(el, binding) {
|
|
33
|
+
const existingTimer = directiveTimerMap.get(el);
|
|
34
|
+
if (existingTimer) {
|
|
35
|
+
clearInterval(existingTimer);
|
|
36
|
+
directiveTimerMap.delete(el);
|
|
37
|
+
}
|
|
38
|
+
const value = binding.value;
|
|
39
|
+
if (value === void 0 || value === null) {
|
|
40
|
+
el.textContent = "";
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const mode = binding.arg || "format";
|
|
44
|
+
const pattern = el.getAttribute("data-pattern") || "YYYY-MM-DD HH:mm:ss";
|
|
45
|
+
const locale = el.getAttribute("data-locale") || void 0;
|
|
46
|
+
const intervalMs = parseInt(el.getAttribute("data-interval") || "60000", 10);
|
|
47
|
+
const numeric = el.getAttribute("data-numeric") || void 0;
|
|
48
|
+
const render = () => {
|
|
49
|
+
try {
|
|
50
|
+
const tg = TimeGuard.from(value);
|
|
51
|
+
if (mode === "relative") {
|
|
52
|
+
const now = TimeGuard.now();
|
|
53
|
+
el.textContent = tg.since(now).humanize({
|
|
54
|
+
locale,
|
|
55
|
+
numeric
|
|
56
|
+
});
|
|
57
|
+
} else el.textContent = locale ? tg.locale(locale).format(pattern) : tg.format(pattern);
|
|
58
|
+
} catch {
|
|
59
|
+
el.textContent = String(value);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
render();
|
|
63
|
+
if (mode === "relative" || el.getAttribute("data-live") === "true") directiveTimerMap.set(el, setInterval(render, intervalMs));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Vue Plugin to register a global TimeGuard configuration and register v-time-guard directive.
|
|
67
|
+
*/
|
|
68
|
+
var TimeGuardVuePlugin = { install(app, options) {
|
|
69
|
+
app.provide(TimeGuardConfigKey, options);
|
|
70
|
+
app.directive("time-guard", vTimeGuard);
|
|
71
|
+
} };
|
|
72
|
+
/**
|
|
73
|
+
* Vue Composable to create a reactive Ref of a TimeGuard instance.
|
|
74
|
+
* Automatically updates when input or configuration changes.
|
|
75
|
+
* Inherits global injected configuration as fallback.
|
|
76
|
+
*/
|
|
77
|
+
function useTimeGuard(input, config) {
|
|
78
|
+
const globalConfig = inject(TimeGuardConfigKey, void 0);
|
|
79
|
+
const activeConfig = config ?? globalConfig;
|
|
80
|
+
const tg = ref(TimeGuard.from(input, activeConfig));
|
|
81
|
+
watch([() => input, () => activeConfig ? JSON.stringify(activeConfig) : void 0], () => {
|
|
82
|
+
tg.value = TimeGuard.from(input, activeConfig);
|
|
83
|
+
}, { deep: true });
|
|
84
|
+
return tg;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Vue Composable to get a reactive TimeGuard Ref representing the current time.
|
|
88
|
+
* Automatically updates on a specified interval (default: 1000ms).
|
|
89
|
+
* Inherits global injected configuration as fallback.
|
|
90
|
+
*/
|
|
91
|
+
function useCurrentTime(options) {
|
|
92
|
+
const globalConfig = inject(TimeGuardConfigKey, void 0);
|
|
93
|
+
const activeConfig = options?.config ?? globalConfig;
|
|
94
|
+
const interval = options?.interval ?? 1e3;
|
|
95
|
+
const time = ref(TimeGuard.now(activeConfig));
|
|
96
|
+
const timer = setInterval(() => {
|
|
97
|
+
time.value = TimeGuard.now(activeConfig);
|
|
98
|
+
}, interval);
|
|
99
|
+
onUnmounted(() => {
|
|
100
|
+
clearInterval(timer);
|
|
101
|
+
});
|
|
102
|
+
return time;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Vue Composable that returns a reactive relative time Ref updating periodically.
|
|
106
|
+
* Inherits global injected configuration as fallback.
|
|
107
|
+
*/
|
|
108
|
+
function useRelativeTime(date, options) {
|
|
109
|
+
const globalConfig = inject(TimeGuardConfigKey, void 0);
|
|
110
|
+
const interval = options?.interval ?? 6e4;
|
|
111
|
+
const locale = options?.locale ?? globalConfig?.locale;
|
|
112
|
+
const numeric = options?.numeric;
|
|
113
|
+
const relative = ref("");
|
|
114
|
+
const update = () => {
|
|
115
|
+
const tgDate = TimeGuard.from(date);
|
|
116
|
+
const now = TimeGuard.now();
|
|
117
|
+
relative.value = tgDate.since(now).humanize({
|
|
118
|
+
locale,
|
|
119
|
+
numeric
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
update();
|
|
123
|
+
const timer = setInterval(update, interval);
|
|
124
|
+
watch([
|
|
125
|
+
() => date,
|
|
126
|
+
() => locale,
|
|
127
|
+
() => numeric
|
|
128
|
+
], () => {
|
|
129
|
+
update();
|
|
130
|
+
}, { deep: true });
|
|
131
|
+
onUnmounted(() => {
|
|
132
|
+
clearInterval(timer);
|
|
133
|
+
});
|
|
134
|
+
return relative;
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
export { TimeGuardConfigKey, TimeGuardVuePlugin, useCurrentTime, useRelativeTime, useTimeGuard, vTimeGuard };
|
package/dist/vue.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Ref, Plugin, Directive } from 'vue';
|
|
2
|
+
import { TimeGuard, ITimeGuardConfig } from './core';
|
|
3
|
+
/**
|
|
4
|
+
* Unique symbol key for injecting TimeGuard global configuration.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TimeGuardConfigKey: unique symbol;
|
|
7
|
+
export declare const vTimeGuard: Directive<HTMLElement, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Vue Plugin to register a global TimeGuard configuration and register v-time-guard directive.
|
|
10
|
+
*/
|
|
11
|
+
export declare const TimeGuardVuePlugin: Plugin;
|
|
12
|
+
/**
|
|
13
|
+
* Vue Composable to create a reactive Ref of a TimeGuard instance.
|
|
14
|
+
* Automatically updates when input or configuration changes.
|
|
15
|
+
* Inherits global injected configuration as fallback.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useTimeGuard(input?: unknown, config?: ITimeGuardConfig): Ref<TimeGuard>;
|
|
18
|
+
/**
|
|
19
|
+
* Vue Composable to get a reactive TimeGuard Ref representing the current time.
|
|
20
|
+
* Automatically updates on a specified interval (default: 1000ms).
|
|
21
|
+
* Inherits global injected configuration as fallback.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useCurrentTime(options?: {
|
|
24
|
+
interval?: number;
|
|
25
|
+
config?: ITimeGuardConfig;
|
|
26
|
+
}): Ref<TimeGuard>;
|
|
27
|
+
/**
|
|
28
|
+
* Vue Composable that returns a reactive relative time Ref updating periodically.
|
|
29
|
+
* Inherits global injected configuration as fallback.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useRelativeTime(date: unknown, options?: {
|
|
32
|
+
interval?: number;
|
|
33
|
+
locale?: string;
|
|
34
|
+
numeric?: 'always' | 'auto';
|
|
35
|
+
}): Ref<string>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bereasoftware/time-guard",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.7.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/time-guard.cjs",
|
|
@@ -19,6 +19,48 @@
|
|
|
19
19
|
"require": "./dist/time-guard.cjs",
|
|
20
20
|
"default": "./dist/time-guard.es.js"
|
|
21
21
|
},
|
|
22
|
+
"./native": {
|
|
23
|
+
"types": "./dist/types/native.d.ts",
|
|
24
|
+
"import": "./dist/native/index.es.js",
|
|
25
|
+
"require": "./dist/native/index.cjs",
|
|
26
|
+
"default": "./dist/native/index.es.js"
|
|
27
|
+
},
|
|
28
|
+
"./react": {
|
|
29
|
+
"types": "./dist/types/react.d.ts",
|
|
30
|
+
"import": "./dist/react/index.es.js",
|
|
31
|
+
"require": "./dist/react/index.cjs",
|
|
32
|
+
"default": "./dist/react/index.es.js"
|
|
33
|
+
},
|
|
34
|
+
"./vue": {
|
|
35
|
+
"types": "./dist/types/vue.d.ts",
|
|
36
|
+
"import": "./dist/vue/index.es.js",
|
|
37
|
+
"require": "./dist/vue/index.cjs",
|
|
38
|
+
"default": "./dist/vue/index.es.js"
|
|
39
|
+
},
|
|
40
|
+
"./angular": {
|
|
41
|
+
"types": "./dist/types/angular.d.ts",
|
|
42
|
+
"import": "./dist/angular/index.es.js",
|
|
43
|
+
"require": "./dist/angular/index.cjs",
|
|
44
|
+
"default": "./dist/angular/index.es.js"
|
|
45
|
+
},
|
|
46
|
+
"./svelte": {
|
|
47
|
+
"types": "./dist/types/svelte.d.ts",
|
|
48
|
+
"import": "./dist/svelte/index.es.js",
|
|
49
|
+
"require": "./dist/svelte/index.cjs",
|
|
50
|
+
"default": "./dist/svelte/index.es.js"
|
|
51
|
+
},
|
|
52
|
+
"./solid": {
|
|
53
|
+
"types": "./dist/types/solid.d.ts",
|
|
54
|
+
"import": "./dist/solid/index.es.js",
|
|
55
|
+
"require": "./dist/solid/index.cjs",
|
|
56
|
+
"default": "./dist/solid/index.es.js"
|
|
57
|
+
},
|
|
58
|
+
"./qwik": {
|
|
59
|
+
"types": "./dist/types/qwik.d.ts",
|
|
60
|
+
"import": "./dist/qwik/index.es.js",
|
|
61
|
+
"require": "./dist/qwik/index.cjs",
|
|
62
|
+
"default": "./dist/qwik/index.es.js"
|
|
63
|
+
},
|
|
22
64
|
"./locales": {
|
|
23
65
|
"types": "./dist/types/locales/index.d.ts",
|
|
24
66
|
"import": "./dist/locales/index.es.js",
|
|
@@ -57,6 +99,7 @@
|
|
|
57
99
|
"registry": "https://registry.npmjs.org/",
|
|
58
100
|
"access": "public"
|
|
59
101
|
},
|
|
102
|
+
"packageManager": "pnpm@11.0.9",
|
|
60
103
|
"keywords": [
|
|
61
104
|
"time-guard",
|
|
62
105
|
"typescript",
|
|
@@ -103,35 +146,86 @@
|
|
|
103
146
|
],
|
|
104
147
|
"homepage": "https://github.com/Berea-Soft/time-guard#readme",
|
|
105
148
|
"scripts": {
|
|
106
|
-
"dev": "
|
|
107
|
-
"build": "
|
|
108
|
-
"
|
|
149
|
+
"dev:docs": "pnpm --prefix docs-app install && pnpm --prefix docs-app dev",
|
|
150
|
+
"build:docs": "pnpm --prefix docs-app build",
|
|
151
|
+
"typecheck:docs": "pnpm --prefix docs-app typecheck",
|
|
152
|
+
"format:docs": "prettier --write \"docs-app/src/**/*.{ts,js,vue,css,json}\" \"docs-app/*.{json,js}\"",
|
|
153
|
+
"format:docs:check": "prettier --check \"docs-app/src/**/*.{ts,js,vue,css,json}\" \"docs-app/*.{json,js}\"",
|
|
154
|
+
"lint:docs": "pnpm --prefix docs-app lint",
|
|
155
|
+
"lint:docs:fix": "pnpm --prefix docs-app lint:fix",
|
|
156
|
+
"build": "vite build && vite build --mode umd && vite build --mode angular",
|
|
157
|
+
"build:all": "pnpm build",
|
|
109
158
|
"test": "vitest run",
|
|
110
159
|
"test:watch": "vitest",
|
|
111
160
|
"test:ui": "vitest --ui",
|
|
112
161
|
"test:coverage": "vitest run --coverage",
|
|
113
|
-
"lint": "
|
|
114
|
-
"lint:fix": "
|
|
162
|
+
"lint": "eslint \"src/**/*.ts\" --max-warnings=0",
|
|
163
|
+
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
115
164
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
116
165
|
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
117
|
-
"
|
|
166
|
+
"typecheck": "tsc --noEmit",
|
|
167
|
+
"prepublishOnly": "pnpm build",
|
|
168
|
+
"prepare": "husky"
|
|
118
169
|
},
|
|
119
170
|
"dependencies": {
|
|
120
|
-
"@js-temporal/polyfill": "^0.5.1"
|
|
171
|
+
"@js-temporal/polyfill": "^0.5.1",
|
|
172
|
+
"vue-icons-plus": "^0.1.9"
|
|
173
|
+
},
|
|
174
|
+
"peerDependencies": {
|
|
175
|
+
"@angular/core": ">=21.2.14",
|
|
176
|
+
"react": ">=19.2.6",
|
|
177
|
+
"rxjs": ">=7.8.2",
|
|
178
|
+
"vue": ">=3.5.34",
|
|
179
|
+
"svelte": ">=5.55.9",
|
|
180
|
+
"solid-js": ">=1.9.13",
|
|
181
|
+
"@builder.io/qwik": ">=1.20.0"
|
|
182
|
+
},
|
|
183
|
+
"peerDependenciesMeta": {
|
|
184
|
+
"react": {
|
|
185
|
+
"optional": true
|
|
186
|
+
},
|
|
187
|
+
"vue": {
|
|
188
|
+
"optional": true
|
|
189
|
+
},
|
|
190
|
+
"@angular/core": {
|
|
191
|
+
"optional": true
|
|
192
|
+
},
|
|
193
|
+
"rxjs": {
|
|
194
|
+
"optional": true
|
|
195
|
+
},
|
|
196
|
+
"svelte": {
|
|
197
|
+
"optional": true
|
|
198
|
+
},
|
|
199
|
+
"solid-js": {
|
|
200
|
+
"optional": true
|
|
201
|
+
},
|
|
202
|
+
"@builder.io/qwik": {
|
|
203
|
+
"optional": true
|
|
204
|
+
}
|
|
121
205
|
},
|
|
122
206
|
"devDependencies": {
|
|
207
|
+
"@angular/core": "^21.2.14",
|
|
123
208
|
"@semantic-release/changelog": "^6.0.3",
|
|
124
209
|
"@semantic-release/git": "^10.0.1",
|
|
125
|
-
"@semantic-release/github": "^12.0.
|
|
210
|
+
"@semantic-release/github": "^12.0.8",
|
|
126
211
|
"@semantic-release/npm": "^13.1.5",
|
|
127
|
-
"@types/node": "^25.
|
|
128
|
-
"@
|
|
129
|
-
"@
|
|
130
|
-
"
|
|
212
|
+
"@types/node": "^25.9.1",
|
|
213
|
+
"@types/react": "^19.2.15",
|
|
214
|
+
"@typescript-eslint/eslint-plugin": "^8.59.4",
|
|
215
|
+
"@typescript-eslint/parser": "^8.59.4",
|
|
216
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
217
|
+
"@vitest/ui": "^4.1.7",
|
|
218
|
+
"eslint": "^10.4.0",
|
|
219
|
+
"husky": "^9.1.7",
|
|
220
|
+
"lint-staged": "^17.0.5",
|
|
221
|
+
"prettier": "^3.8.3",
|
|
222
|
+
"react": "^19.2.6",
|
|
223
|
+
"rxjs": "^7.8.2",
|
|
131
224
|
"semantic-release": "^25.0.3",
|
|
132
|
-
"typescript": "~6.0.
|
|
133
|
-
"vite": "^8.0.
|
|
134
|
-
"vite-plugin-dts": "^
|
|
135
|
-
"vitest": "^4.1.
|
|
225
|
+
"typescript": "~6.0.3",
|
|
226
|
+
"vite": "^8.0.14",
|
|
227
|
+
"vite-plugin-dts": "^5.0.1",
|
|
228
|
+
"vitest": "^4.1.7",
|
|
229
|
+
"vue": "^3.5.34"
|
|
136
230
|
}
|
|
137
231
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/calendars/index.ts"],"sourcesContent":["/**\r\n * Alternative Calendar Systems\r\n * Extended calendar support for international use\r\n */\r\n\r\nimport type { ICalendarSystem } from '../types';\r\n\r\n/**\r\n * Islamic Calendar (Hijri)\r\n * @experimental Uses simplified calculations. May not be accurate for all dates.\r\n */\r\nexport class IslamicCalendar implements ICalendarSystem {\r\n readonly id = 'islamic';\r\n readonly name = 'Islamic Calendar (Hijri)';\r\n readonly locale = 'ar';\r\n\r\n private monthNames = [\r\n 'Muharram', 'Safar', 'Rabi al-awwal', 'Rabi al-thani',\r\n 'Jumada al-awwal', 'Jumada al-thani', 'Rajab', 'Sha\\'ban',\r\n 'Ramadan', 'Shawwal', 'Dhu al-Qi\\'dah', 'Dhu al-Hijjah'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number, short: boolean = false): string {\r\n const weekdays = short\r\n ? ['Ahd', 'Ith', 'Sel', 'Rab', 'Kha', 'Jum', 'Sab']\r\n : ['Ahad', 'Ithnayn', 'Salasa', 'Rabi', 'Khamis', 'Jumah', 'Sabt'];\r\n return weekdays[Math.max(0, Math.min(6, day - 1))];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Islamic leap year: years 2, 5, 7, 10, 13, 16, 18, 21, 24, 26, 29 in 30-year cycle\r\n return [2, 5, 7, 10, 13, 16, 18, 21, 24, 26, 29].includes(year % 30);\r\n }\r\n\r\n daysInMonth(year: number, month: number): number {\r\n // Islamic months: odd months have 30 days, even months have 29 days\r\n // except last month which has 30 on leap years\r\n if (month % 2 === 1) return 30;\r\n if (month === 12 && this.isLeapYear(year)) return 30;\r\n return 29;\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 355 : 354;\r\n }\r\n}\r\n\r\n/**\r\n * Hebrew Calendar\r\n * @experimental Uses simplified calculations. May not be accurate for all dates.\r\n */\r\nexport class HebrewCalendar implements ICalendarSystem {\r\n readonly id = 'hebrew';\r\n readonly name = 'Hebrew Calendar';\r\n readonly locale = 'he';\r\n\r\n private monthNames = [\r\n 'Tishrei', 'Cheshvan', 'Kislev', 'Tevet', 'Shevat', 'Adar',\r\n 'Nisan', 'Iyar', 'Sivan', 'Tammuz', 'Av', 'Elul'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number, short: boolean = false): string {\r\n const weekdays = short\r\n ? ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']\r\n : ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\r\n return weekdays[Math.max(0, Math.min(6, day - 1))];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Hebrew leap year: years 3, 6, 8, 11, 14, 17, 19 in 19-year cycle\r\n return [3, 6, 8, 11, 14, 17, 19].includes(year % 19);\r\n }\r\n\r\n daysInMonth(_year: number, month: number): number {\r\n // Simplified version - actual Hebrew calendar is more complex\r\n const daysPerMonth = [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29];\r\n return daysPerMonth[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 384 : 354;\r\n }\r\n}\r\n\r\n/**\r\n * Chinese Calendar\r\n * @experimental Uses simplified calculations. May not be accurate for all dates.\r\n */\r\nexport class ChineseCalendar implements ICalendarSystem {\r\n readonly id = 'chinese';\r\n readonly name = 'Chinese Calendar';\r\n readonly locale = 'zh';\r\n\r\n private monthNames = [\r\n '正月', '二月', '三月', '四月', '五月', '六月',\r\n '七月', '八月', '九月', '十月', '冬月', '腊月'\r\n ];\r\n\r\n private terrestrialBranches = [\r\n '子', '丑', '寅', '卯', '辰', '巳',\r\n '午', '未', '申', '酉', '戌', '亥'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number, short: boolean = false): string {\r\n const weekdays = short\r\n ? ['日', '一', '二', '三', '四', '五', '六']\r\n : ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];\r\n return weekdays[Math.max(0, Math.min(6, day - 1))];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Chinese leap year follows a different cycle\r\n return year % 3 === 0;\r\n }\r\n\r\n daysInMonth(_year: number, month: number): number {\r\n return month % 2 === 0 ? 30 : 29;\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 384 : 354;\r\n }\r\n\r\n /**\r\n * Get zodiac sign for year\r\n */\r\n getZodiacSign(year: number): string {\r\n return this.terrestrialBranches[year % 12];\r\n }\r\n}\r\n\r\n/**\r\n * Japanese Calendar\r\n * @experimental Uses Gregorian rules post-1873. Historical dates may not be accurate.\r\n */\r\nexport class JapaneseCalendar implements ICalendarSystem {\r\n readonly id = 'japanese';\r\n readonly name = 'Japanese Calendar';\r\n readonly locale = 'ja';\r\n\r\n private monthNames = [\r\n '1月', '2月', '3月', '4月', '5月', '6月',\r\n '7月', '8月', '9月', '10月', '11月', '12月'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number, short: boolean = false): string {\r\n const weekdays = short\r\n ? ['日', '月', '火', '水', '木', '金', '土']\r\n : ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'];\r\n return weekdays[Math.max(0, Math.min(6, day - 1))];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Japanese calendar adopted Gregorian calendar in 1873\r\n // Uses same leap year rules as Gregorian\r\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\r\n }\r\n\r\n daysInMonth(year: number, month: number): number {\r\n const daysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\r\n if (month === 2 && this.isLeapYear(year)) {\r\n return 29;\r\n }\r\n return daysPerMonth[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 366 : 365;\r\n }\r\n}\r\n\r\n/**\r\n * Buddhist Calendar\r\n * @experimental Uses Gregorian rules with BE year offset (CE + 543).\r\n */\r\nexport class BuddhistCalendar implements ICalendarSystem {\r\n readonly id = 'buddhist';\r\n readonly name = 'Buddhist Calendar';\r\n readonly locale = 'th';\r\n\r\n private monthNames = [\r\n 'January', 'February', 'March', 'April', 'May', 'June',\r\n 'July', 'August', 'September', 'October', 'November', 'December'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number): string {\r\n return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][\r\n Math.max(0, Math.min(6, day - 1))\r\n ];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Buddhist Era = CE + 543\r\n const ceYear = year - 543;\r\n return (ceYear % 4 === 0 && ceYear % 100 !== 0) || ceYear % 400 === 0;\r\n }\r\n\r\n daysInMonth(year: number, month: number): number {\r\n // Same as Gregorian\r\n const daysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\r\n if (month === 2 && this.isLeapYear(year)) {\r\n return 29;\r\n }\r\n return daysPerMonth[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 366 : 365;\r\n }\r\n}\r\n"],"mappings":"mEAWA,IAAa,EAAb,KAAwD,CACtD,GAAc,UACd,KAAgB,2BAChB,OAAkB,KAElB,WAAqB,CACnB,WAAY,QAAS,gBAAiB,gBACtC,kBAAmB,kBAAmB,QAAS,UAC/C,UAAW,UAAW,gBAAkB,gBACzC,CAED,aAAa,EAAuB,CAClC,OAAO,KAAK,WAAW,KAAK,IAAI,EAAG,KAAK,IAAI,GAAI,EAAQ,EAAE,CAAC,EAG7D,eAAe,EAAa,EAAiB,GAAe,CAI1D,OAHiB,EACb,CAAC,MAAO,MAAO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|
1
|
-
{"version":3,"file":"index.es.js","names":[],"sources":["../../src/calendars/index.ts"],"sourcesContent":["/**\r\n * Alternative Calendar Systems\r\n * Extended calendar support for international use\r\n */\r\n\r\nimport type { ICalendarSystem } from '../types';\r\n\r\n/**\r\n * Islamic Calendar (Hijri)\r\n * @experimental Uses simplified calculations. May not be accurate for all dates.\r\n */\r\nexport class IslamicCalendar implements ICalendarSystem {\r\n readonly id = 'islamic';\r\n readonly name = 'Islamic Calendar (Hijri)';\r\n readonly locale = 'ar';\r\n\r\n private monthNames = [\r\n 'Muharram', 'Safar', 'Rabi al-awwal', 'Rabi al-thani',\r\n 'Jumada al-awwal', 'Jumada al-thani', 'Rajab', 'Sha\\'ban',\r\n 'Ramadan', 'Shawwal', 'Dhu al-Qi\\'dah', 'Dhu al-Hijjah'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number, short: boolean = false): string {\r\n const weekdays = short\r\n ? ['Ahd', 'Ith', 'Sel', 'Rab', 'Kha', 'Jum', 'Sab']\r\n : ['Ahad', 'Ithnayn', 'Salasa', 'Rabi', 'Khamis', 'Jumah', 'Sabt'];\r\n return weekdays[Math.max(0, Math.min(6, day - 1))];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Islamic leap year: years 2, 5, 7, 10, 13, 16, 18, 21, 24, 26, 29 in 30-year cycle\r\n return [2, 5, 7, 10, 13, 16, 18, 21, 24, 26, 29].includes(year % 30);\r\n }\r\n\r\n daysInMonth(year: number, month: number): number {\r\n // Islamic months: odd months have 30 days, even months have 29 days\r\n // except last month which has 30 on leap years\r\n if (month % 2 === 1) return 30;\r\n if (month === 12 && this.isLeapYear(year)) return 30;\r\n return 29;\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 355 : 354;\r\n }\r\n}\r\n\r\n/**\r\n * Hebrew Calendar\r\n * @experimental Uses simplified calculations. May not be accurate for all dates.\r\n */\r\nexport class HebrewCalendar implements ICalendarSystem {\r\n readonly id = 'hebrew';\r\n readonly name = 'Hebrew Calendar';\r\n readonly locale = 'he';\r\n\r\n private monthNames = [\r\n 'Tishrei', 'Cheshvan', 'Kislev', 'Tevet', 'Shevat', 'Adar',\r\n 'Nisan', 'Iyar', 'Sivan', 'Tammuz', 'Av', 'Elul'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number, short: boolean = false): string {\r\n const weekdays = short\r\n ? ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']\r\n : ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\r\n return weekdays[Math.max(0, Math.min(6, day - 1))];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Hebrew leap year: years 3, 6, 8, 11, 14, 17, 19 in 19-year cycle\r\n return [3, 6, 8, 11, 14, 17, 19].includes(year % 19);\r\n }\r\n\r\n daysInMonth(_year: number, month: number): number {\r\n // Simplified version - actual Hebrew calendar is more complex\r\n const daysPerMonth = [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29];\r\n return daysPerMonth[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 384 : 354;\r\n }\r\n}\r\n\r\n/**\r\n * Chinese Calendar\r\n * @experimental Uses simplified calculations. May not be accurate for all dates.\r\n */\r\nexport class ChineseCalendar implements ICalendarSystem {\r\n readonly id = 'chinese';\r\n readonly name = 'Chinese Calendar';\r\n readonly locale = 'zh';\r\n\r\n private monthNames = [\r\n '正月', '二月', '三月', '四月', '五月', '六月',\r\n '七月', '八月', '九月', '十月', '冬月', '腊月'\r\n ];\r\n\r\n private terrestrialBranches = [\r\n '子', '丑', '寅', '卯', '辰', '巳',\r\n '午', '未', '申', '酉', '戌', '亥'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number, short: boolean = false): string {\r\n const weekdays = short\r\n ? ['日', '一', '二', '三', '四', '五', '六']\r\n : ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];\r\n return weekdays[Math.max(0, Math.min(6, day - 1))];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Chinese leap year follows a different cycle\r\n return year % 3 === 0;\r\n }\r\n\r\n daysInMonth(_year: number, month: number): number {\r\n return month % 2 === 0 ? 30 : 29;\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 384 : 354;\r\n }\r\n\r\n /**\r\n * Get zodiac sign for year\r\n */\r\n getZodiacSign(year: number): string {\r\n return this.terrestrialBranches[year % 12];\r\n }\r\n}\r\n\r\n/**\r\n * Japanese Calendar\r\n * @experimental Uses Gregorian rules post-1873. Historical dates may not be accurate.\r\n */\r\nexport class JapaneseCalendar implements ICalendarSystem {\r\n readonly id = 'japanese';\r\n readonly name = 'Japanese Calendar';\r\n readonly locale = 'ja';\r\n\r\n private monthNames = [\r\n '1月', '2月', '3月', '4月', '5月', '6月',\r\n '7月', '8月', '9月', '10月', '11月', '12月'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number, short: boolean = false): string {\r\n const weekdays = short\r\n ? ['日', '月', '火', '水', '木', '金', '土']\r\n : ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'];\r\n return weekdays[Math.max(0, Math.min(6, day - 1))];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Japanese calendar adopted Gregorian calendar in 1873\r\n // Uses same leap year rules as Gregorian\r\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\r\n }\r\n\r\n daysInMonth(year: number, month: number): number {\r\n const daysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\r\n if (month === 2 && this.isLeapYear(year)) {\r\n return 29;\r\n }\r\n return daysPerMonth[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 366 : 365;\r\n }\r\n}\r\n\r\n/**\r\n * Buddhist Calendar\r\n * @experimental Uses Gregorian rules with BE year offset (CE + 543).\r\n */\r\nexport class BuddhistCalendar implements ICalendarSystem {\r\n readonly id = 'buddhist';\r\n readonly name = 'Buddhist Calendar';\r\n readonly locale = 'th';\r\n\r\n private monthNames = [\r\n 'January', 'February', 'March', 'April', 'May', 'June',\r\n 'July', 'August', 'September', 'October', 'November', 'December'\r\n ];\r\n\r\n getMonthName(month: number): string {\r\n return this.monthNames[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n getWeekdayName(day: number): string {\r\n return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][\r\n Math.max(0, Math.min(6, day - 1))\r\n ];\r\n }\r\n\r\n isLeapYear(year: number): boolean {\r\n // Buddhist Era = CE + 543\r\n const ceYear = year - 543;\r\n return (ceYear % 4 === 0 && ceYear % 100 !== 0) || ceYear % 400 === 0;\r\n }\r\n\r\n daysInMonth(year: number, month: number): number {\r\n // Same as Gregorian\r\n const daysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\r\n if (month === 2 && this.isLeapYear(year)) {\r\n return 29;\r\n }\r\n return daysPerMonth[Math.max(0, Math.min(11, month - 1))];\r\n }\r\n\r\n daysInYear(year: number): number {\r\n return this.isLeapYear(year) ? 366 : 365;\r\n }\r\n}\r\n"],"mappings":";;AAWA,IAAa,IAAb,MAAwD;CACtD,KAAc;CACd,OAAgB;CAChB,SAAkB;CAElB,aAAqB;EACnB;EAAY;EAAS;EAAiB;EACtC;EAAmB;EAAmB;EAAS;EAC/C;EAAW;EAAW;EAAkB;EACzC;CA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