dayjskh 0.1.12 → 0.2.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.
- package/dist/dayjskh.es.js +524 -0
- package/dist/dayjskh.umd.js +1 -0
- package/package.json +23 -10
- package/types/index.d.ts +1 -1
- package/.editorconfig +0 -20
- package/.prettierrc.json +0 -1
- package/index.html +0 -54
- package/src/constant.ts +0 -80
- package/src/dayjskh.ts.Deprecation +0 -500
- package/src/khmerNewYear.ts +0 -95
- package/src/khmercal.ts +0 -198
- package/src/lerngSak.ts +0 -284
- package/src/main.ts +0 -19
- package/src/utils.ts +0 -79
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -23
- package/vite.config.js +0 -6
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
import P from "dayjs";
|
|
2
|
+
"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_").forEach((e, o) => o);
|
|
3
|
+
"ជូត_ឆ្លូវ_ខាល_ថោះ_រោង_ម្សាញ់_មមី_មមែ_វក_រកា_ច_កុរ".split("_").forEach((e, o) => o);
|
|
4
|
+
"សំរឹទ្ធិស័ក_ឯកស័ក_ទោស័ក_ត្រីស័ក_ចត្វាស័ក_បញ្ចស័ក_ឆស័ក_សប្តស័ក_អដ្ឋស័ក_នព្វស័ក".split("_").forEach((e, o) => o);
|
|
5
|
+
"កើត_រោច".split("_").forEach((e, o) => o);
|
|
6
|
+
const ct = {
|
|
7
|
+
1879: "12-04-1879 11:36",
|
|
8
|
+
1897: "13-04-1897 02:00",
|
|
9
|
+
2011: "14-04-2011 13:12",
|
|
10
|
+
2012: "14-04-2012 19:11",
|
|
11
|
+
2013: "14-04-2013 02:12",
|
|
12
|
+
2014: "14-04-2014 08:07",
|
|
13
|
+
2015: "14-04-2015 14:02",
|
|
14
|
+
2016: "14-04-2016 07:53",
|
|
15
|
+
2017: "14-04-2017 13:48",
|
|
16
|
+
2018: "14-04-2018 19:43",
|
|
17
|
+
2019: "14-04-2019 01:38",
|
|
18
|
+
2020: "14-04-2020 07:33",
|
|
19
|
+
2021: "14-04-2021 13:28",
|
|
20
|
+
2022: "14-04-2022 19:23",
|
|
21
|
+
2023: "14-04-2023 01:18",
|
|
22
|
+
2024: "13-04-2024 22:17",
|
|
23
|
+
2025: "14-04-2025 10:04",
|
|
24
|
+
2026: "14-04-2026 10:48",
|
|
25
|
+
2027: "14-04-2027 16:43",
|
|
26
|
+
2028: "13-04-2028 23:12",
|
|
27
|
+
2029: "14-04-2029 10:33",
|
|
28
|
+
2030: "14-04-2030 16:28"
|
|
29
|
+
}, ft = {
|
|
30
|
+
2016: 3
|
|
31
|
+
// Official declaration was 3 days despite astronomical 4
|
|
32
|
+
}, ht = () => {
|
|
33
|
+
const e = ["១", "២", "៣", "៤", "៥", "៦", "៧", "៨", "៩", "០"], o = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
|
|
34
|
+
return {
|
|
35
|
+
months: "មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split(
|
|
36
|
+
"_"
|
|
37
|
+
),
|
|
38
|
+
monthsShort: "មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split(
|
|
39
|
+
"_"
|
|
40
|
+
),
|
|
41
|
+
moonDays: "᧡_᧢_᧣_᧤_᧥_᧦_᧧_᧨_᧩_᧪_᧫_᧬_᧭_᧮_᧯_᧱_᧲_᧳_᧴_᧵_᧶_᧷_᧸_᧹_᧺_᧻_᧼_᧽_᧾_᧿".split("_"),
|
|
42
|
+
moonStatus: "កើត_រោច".split("_"),
|
|
43
|
+
moonStatusShort: "ក_រ".split("_"),
|
|
44
|
+
weekdays: "អាទិត្យ_ចន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍".split("_"),
|
|
45
|
+
weekdaysShort: "អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),
|
|
46
|
+
weekdaysMin: "អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),
|
|
47
|
+
lunarMonths: "មិគសិរ_បុស្ស_មាឃ_ផល្គុន_ចេត្រ_ពិសាខ_ជេស្ឋ_អាសាឍ_ស្រាពណ៍_ភទ្របទ_អស្សុជ_កត្តិក_បឋមាសាឍ_ទុតិយាសាឍ".split(
|
|
48
|
+
"_"
|
|
49
|
+
),
|
|
50
|
+
animalYear: "ជូត_ឆ្លូវ_ខាល_ថោះ_រោង_ម្សាញ់_មមីរ_មមែ_វក_រកា_ច_កុរ".split("_"),
|
|
51
|
+
eraYear: "សំរឹទ្ធិស័ក_ឯកស័ក_ទោស័ក_ត្រីស័ក_ចត្វាស័ក_បញ្ចស័ក_ឆស័ក_សប្តស័ក_អដ្ឋស័ក_នព្វស័ក".split(
|
|
52
|
+
"_"
|
|
53
|
+
),
|
|
54
|
+
preparse: function(i) {
|
|
55
|
+
return i.replace(/[១២៣៤៥៦៧៨៩០]/g, (f) => o[e.indexOf(f)]);
|
|
56
|
+
},
|
|
57
|
+
postformat: function(i) {
|
|
58
|
+
return i.replace(/[1234567890]/g, (f) => e[o.indexOf(Number(f))]);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}, b = {
|
|
62
|
+
khNewYear: ct,
|
|
63
|
+
khNewYearDays: ft,
|
|
64
|
+
kh: ht()
|
|
65
|
+
};
|
|
66
|
+
function _t(e = P()) {
|
|
67
|
+
const o = (r) => (r * 292207 + 373) % 800, i = (r) => Math.floor((r * 292207 + 373) / 800) + 1, f = (r) => (11 * i(r) + 650) % 692, m = (r) => 800 - o(r) <= 207;
|
|
68
|
+
function y(r) {
|
|
69
|
+
const a = i(r);
|
|
70
|
+
return (a + Math.floor((11 * a + 650) / 692)) % 30;
|
|
71
|
+
}
|
|
72
|
+
function g(r) {
|
|
73
|
+
let a = 0, c = 1333, d = r.year() - 638;
|
|
74
|
+
if (c > d) {
|
|
75
|
+
let p = c;
|
|
76
|
+
c = d, d = p;
|
|
77
|
+
}
|
|
78
|
+
for (; c < d; ) a += M(c++);
|
|
79
|
+
return a;
|
|
80
|
+
}
|
|
81
|
+
function M(r) {
|
|
82
|
+
return w(r) ? 384 : L(r) ? 355 : 354;
|
|
83
|
+
}
|
|
84
|
+
function w(r) {
|
|
85
|
+
const a = y(r), c = y(r + 1);
|
|
86
|
+
return a > 24 || a < 6 || a === 24 && c === 6 || a === 25 && c === 5;
|
|
87
|
+
}
|
|
88
|
+
function N(r) {
|
|
89
|
+
const a = k(r);
|
|
90
|
+
return { month: 3 + +(a >= 6 && a <= 29), day: a };
|
|
91
|
+
}
|
|
92
|
+
function k(r) {
|
|
93
|
+
const a = y(r), c = w(r - 1);
|
|
94
|
+
return !c || c && !x(r - 1) ? a < 6 ? a + 1 : a : a + 1;
|
|
95
|
+
}
|
|
96
|
+
function L(r) {
|
|
97
|
+
let a = x(r);
|
|
98
|
+
return w(r) && a && (a = !1), a;
|
|
99
|
+
}
|
|
100
|
+
function x(r) {
|
|
101
|
+
const a = f(r), c = f(r + 1), d = m(r);
|
|
102
|
+
let p = d && a < 127;
|
|
103
|
+
return d || (a === 137 && c === 0 ? p = !1 : a < 138 && (p = !0)), p || (p = x(r - 1) && w(r - 1)), p;
|
|
104
|
+
}
|
|
105
|
+
function C(r) {
|
|
106
|
+
return Math.abs(
|
|
107
|
+
Math.round((r.valueOf() - 286596e5) / 864e5)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
function A(r) {
|
|
111
|
+
const a = w(r), c = L(r), d = [];
|
|
112
|
+
for (let p = 0; p < 12 + Number(a); p++) {
|
|
113
|
+
let v = p;
|
|
114
|
+
a && v >= 8 && v--, d.push(29 + +(v % 2 != 0) + (v === 6 && c ? 1 : 0));
|
|
115
|
+
}
|
|
116
|
+
return d;
|
|
117
|
+
}
|
|
118
|
+
typeof e == "string" && (e = P(e)), e = e.subtract(7, "hour");
|
|
119
|
+
const l = e.year();
|
|
120
|
+
let t = l - 638, n = Math.abs(C(e) - g(e)) + 1;
|
|
121
|
+
const u = l + 543 + +(n > 162), s = M(t);
|
|
122
|
+
n > s && (n -= s, t++);
|
|
123
|
+
let _ = 0;
|
|
124
|
+
const Y = A(t);
|
|
125
|
+
for (const r of Y) {
|
|
126
|
+
if (n <= r) break;
|
|
127
|
+
n -= r, _++;
|
|
128
|
+
}
|
|
129
|
+
const O = N(t - 1), D = t - 1 - +(O.month > _ || O.month === _ && O.day > e.date()), S = [
|
|
130
|
+
"មិគសិរ",
|
|
131
|
+
"បុស្ស",
|
|
132
|
+
"មាឃ",
|
|
133
|
+
"ផល្គុន",
|
|
134
|
+
"ចេត្រ",
|
|
135
|
+
"ពិសាខ",
|
|
136
|
+
"ជេស្ឋ",
|
|
137
|
+
"អាសាឍ",
|
|
138
|
+
"បឋមាសាឍ",
|
|
139
|
+
"ទុតិយាសាឍ",
|
|
140
|
+
"ស្រាពណ៍",
|
|
141
|
+
"ភទ្របទ",
|
|
142
|
+
"អស្សុជ",
|
|
143
|
+
"កត្តិក"
|
|
144
|
+
].filter((r, a) => Y.length == 12 ? a != 8 && a != 9 : a != 7), h = [
|
|
145
|
+
"ជូត",
|
|
146
|
+
"ឆ្លូវ",
|
|
147
|
+
"ខាល",
|
|
148
|
+
"ថោះ",
|
|
149
|
+
"រោង",
|
|
150
|
+
"ម្សាញ់",
|
|
151
|
+
"មមីរ",
|
|
152
|
+
"មមែ",
|
|
153
|
+
"វក",
|
|
154
|
+
"រកា",
|
|
155
|
+
"ច",
|
|
156
|
+
"កុរ"
|
|
157
|
+
];
|
|
158
|
+
return {
|
|
159
|
+
day: n,
|
|
160
|
+
period: {
|
|
161
|
+
day: (n - 1) % 15 + 1,
|
|
162
|
+
moon: n > 15 ? "រោច" : "កើត"
|
|
163
|
+
},
|
|
164
|
+
// sequence: (((JE + 1) % 10) + 9) % 10,
|
|
165
|
+
// sak: SAK[(((JE + 1) % 10) + 9) % 10],
|
|
166
|
+
zodiac: h[((D + 1) % 12 + 10) % 12],
|
|
167
|
+
years: {
|
|
168
|
+
JE: D,
|
|
169
|
+
CE: l,
|
|
170
|
+
BE: u
|
|
171
|
+
},
|
|
172
|
+
length: s,
|
|
173
|
+
monthLength: Y[_],
|
|
174
|
+
month: { name: S[_], index: _ },
|
|
175
|
+
months: S
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function mt(e) {
|
|
179
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
180
|
+
}
|
|
181
|
+
var R = { exports: {} }, dt = R.exports, nt;
|
|
182
|
+
function yt() {
|
|
183
|
+
return nt || (nt = 1, (function(e, o) {
|
|
184
|
+
(function(i, f) {
|
|
185
|
+
e.exports = f();
|
|
186
|
+
})(dt, (function() {
|
|
187
|
+
var i = { LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D, YYYY", LLL: "MMMM D, YYYY h:mm A", LLLL: "dddd, MMMM D, YYYY h:mm A" }, f = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, m = /\d/, y = /\d\d/, g = /\d\d?/, M = /\d*[^-_:/,()\s\d]+/, w = {}, N = function(t) {
|
|
188
|
+
return (t = +t) + (t > 68 ? 1900 : 2e3);
|
|
189
|
+
}, k = function(t) {
|
|
190
|
+
return function(n) {
|
|
191
|
+
this[t] = +n;
|
|
192
|
+
};
|
|
193
|
+
}, L = [/[+-]\d\d:?(\d\d)?|Z/, function(t) {
|
|
194
|
+
(this.zone || (this.zone = {})).offset = (function(n) {
|
|
195
|
+
if (!n || n === "Z") return 0;
|
|
196
|
+
var u = n.match(/([+-]|\d\d)/g), s = 60 * u[1] + (+u[2] || 0);
|
|
197
|
+
return s === 0 ? 0 : u[0] === "+" ? -s : s;
|
|
198
|
+
})(t);
|
|
199
|
+
}], x = function(t) {
|
|
200
|
+
var n = w[t];
|
|
201
|
+
return n && (n.indexOf ? n : n.s.concat(n.f));
|
|
202
|
+
}, C = function(t, n) {
|
|
203
|
+
var u, s = w.meridiem;
|
|
204
|
+
if (s) {
|
|
205
|
+
for (var _ = 1; _ <= 24; _ += 1) if (t.indexOf(s(_, 0, n)) > -1) {
|
|
206
|
+
u = _ > 12;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
} else u = t === (n ? "pm" : "PM");
|
|
210
|
+
return u;
|
|
211
|
+
}, A = { A: [M, function(t) {
|
|
212
|
+
this.afternoon = C(t, !1);
|
|
213
|
+
}], a: [M, function(t) {
|
|
214
|
+
this.afternoon = C(t, !0);
|
|
215
|
+
}], Q: [m, function(t) {
|
|
216
|
+
this.month = 3 * (t - 1) + 1;
|
|
217
|
+
}], S: [m, function(t) {
|
|
218
|
+
this.milliseconds = 100 * +t;
|
|
219
|
+
}], SS: [y, function(t) {
|
|
220
|
+
this.milliseconds = 10 * +t;
|
|
221
|
+
}], SSS: [/\d{3}/, function(t) {
|
|
222
|
+
this.milliseconds = +t;
|
|
223
|
+
}], s: [g, k("seconds")], ss: [g, k("seconds")], m: [g, k("minutes")], mm: [g, k("minutes")], H: [g, k("hours")], h: [g, k("hours")], HH: [g, k("hours")], hh: [g, k("hours")], D: [g, k("day")], DD: [y, k("day")], Do: [M, function(t) {
|
|
224
|
+
var n = w.ordinal, u = t.match(/\d+/);
|
|
225
|
+
if (this.day = u[0], n) for (var s = 1; s <= 31; s += 1) n(s).replace(/\[|\]/g, "") === t && (this.day = s);
|
|
226
|
+
}], w: [g, k("week")], ww: [y, k("week")], M: [g, k("month")], MM: [y, k("month")], MMM: [M, function(t) {
|
|
227
|
+
var n = x("months"), u = (x("monthsShort") || n.map((function(s) {
|
|
228
|
+
return s.slice(0, 3);
|
|
229
|
+
}))).indexOf(t) + 1;
|
|
230
|
+
if (u < 1) throw new Error();
|
|
231
|
+
this.month = u % 12 || u;
|
|
232
|
+
}], MMMM: [M, function(t) {
|
|
233
|
+
var n = x("months").indexOf(t) + 1;
|
|
234
|
+
if (n < 1) throw new Error();
|
|
235
|
+
this.month = n % 12 || n;
|
|
236
|
+
}], Y: [/[+-]?\d+/, k("year")], YY: [y, function(t) {
|
|
237
|
+
this.year = N(t);
|
|
238
|
+
}], YYYY: [/\d{4}/, k("year")], Z: L, ZZ: L };
|
|
239
|
+
function l(t) {
|
|
240
|
+
var n, u;
|
|
241
|
+
n = t, u = w && w.formats;
|
|
242
|
+
for (var s = (t = n.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (function(r, a, c) {
|
|
243
|
+
var d = c && c.toUpperCase();
|
|
244
|
+
return a || u[c] || i[c] || u[d].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (function(p, v, E) {
|
|
245
|
+
return v || E.slice(1);
|
|
246
|
+
}));
|
|
247
|
+
}))).match(f), _ = s.length, Y = 0; Y < _; Y += 1) {
|
|
248
|
+
var O = s[Y], D = A[O], S = D && D[0], h = D && D[1];
|
|
249
|
+
s[Y] = h ? { regex: S, parser: h } : O.replace(/^\[|\]$/g, "");
|
|
250
|
+
}
|
|
251
|
+
return function(r) {
|
|
252
|
+
for (var a = {}, c = 0, d = 0; c < _; c += 1) {
|
|
253
|
+
var p = s[c];
|
|
254
|
+
if (typeof p == "string") d += p.length;
|
|
255
|
+
else {
|
|
256
|
+
var v = p.regex, E = p.parser, T = r.slice(d), H = v.exec(T)[0];
|
|
257
|
+
E.call(a, H), r = r.replace(H, "");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return (function(I) {
|
|
261
|
+
var Z = I.afternoon;
|
|
262
|
+
if (Z !== void 0) {
|
|
263
|
+
var $ = I.hours;
|
|
264
|
+
Z ? $ < 12 && (I.hours += 12) : $ === 12 && (I.hours = 0), delete I.afternoon;
|
|
265
|
+
}
|
|
266
|
+
})(a), a;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
return function(t, n, u) {
|
|
270
|
+
u.p.customParseFormat = !0, t && t.parseTwoDigitYear && (N = t.parseTwoDigitYear);
|
|
271
|
+
var s = n.prototype, _ = s.parse;
|
|
272
|
+
s.parse = function(Y) {
|
|
273
|
+
var O = Y.date, D = Y.utc, S = Y.args;
|
|
274
|
+
this.$u = D;
|
|
275
|
+
var h = S[1];
|
|
276
|
+
if (typeof h == "string") {
|
|
277
|
+
var r = S[2] === !0, a = S[3] === !0, c = r || a, d = S[2];
|
|
278
|
+
a && (d = S[2]), w = this.$locale(), !r && d && (w = u.Ls[d]), this.$d = (function(T, H, I, Z) {
|
|
279
|
+
try {
|
|
280
|
+
if (["x", "X"].indexOf(H) > -1) return new Date((H === "X" ? 1e3 : 1) * T);
|
|
281
|
+
var $ = l(H)(T), q = $.year, z = $.month, ot = $.day, st = $.hours, it = $.minutes, ut = $.seconds, lt = $.milliseconds, tt = $.zone, et = $.week, B = /* @__PURE__ */ new Date(), U = ot || (q || z ? 1 : B.getDate()), Q = q || B.getFullYear(), J = 0;
|
|
282
|
+
q && !z || (J = z > 0 ? z - 1 : B.getMonth());
|
|
283
|
+
var V, W = st || 0, X = it || 0, G = ut || 0, K = lt || 0;
|
|
284
|
+
return tt ? new Date(Date.UTC(Q, J, U, W, X, G, K + 60 * tt.offset * 1e3)) : I ? new Date(Date.UTC(Q, J, U, W, X, G, K)) : (V = new Date(Q, J, U, W, X, G, K), et && (V = Z(V).week(et).toDate()), V);
|
|
285
|
+
} catch {
|
|
286
|
+
return /* @__PURE__ */ new Date("");
|
|
287
|
+
}
|
|
288
|
+
})(O, h, D, u), this.init(), d && d !== !0 && (this.$L = this.locale(d).$L), c && O != this.format(h) && (this.$d = /* @__PURE__ */ new Date("")), w = {};
|
|
289
|
+
} else if (h instanceof Array) for (var p = h.length, v = 1; v <= p; v += 1) {
|
|
290
|
+
S[1] = h[v - 1];
|
|
291
|
+
var E = u.apply(this, S);
|
|
292
|
+
if (E.isValid()) {
|
|
293
|
+
this.$d = E.$d, this.$L = E.$L, this.init();
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
v === p && (this.$d = /* @__PURE__ */ new Date(""));
|
|
297
|
+
}
|
|
298
|
+
else _.call(this, Y);
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
}));
|
|
302
|
+
})(R)), R.exports;
|
|
303
|
+
}
|
|
304
|
+
var pt = yt();
|
|
305
|
+
const gt = /* @__PURE__ */ mt(pt);
|
|
306
|
+
function kt(e = P().year()) {
|
|
307
|
+
arguments.length === 0 ? e = P().year() : e = arguments[0];
|
|
308
|
+
const o = (l) => {
|
|
309
|
+
let t = 292207 * l + 373, n = Math.floor(t / 800) + 1, u = 800 - t % 800, s = 11 * n + 650, _ = s % 692, Y = (n + Math.floor(s / 692)) % 30;
|
|
310
|
+
return {
|
|
311
|
+
harkun: n,
|
|
312
|
+
kromathopol: u,
|
|
313
|
+
avaman: _,
|
|
314
|
+
bodithey: Y
|
|
315
|
+
};
|
|
316
|
+
}, i = (l) => {
|
|
317
|
+
const { kromathopol: t } = o(l);
|
|
318
|
+
return t <= 207;
|
|
319
|
+
}, f = (l) => {
|
|
320
|
+
const { bodithey: t } = o(l), { bodithey: n } = o(l + 1);
|
|
321
|
+
return !(t === 25 && n === 5) && (t > 24 || n < 6 || t === 24 && n === 6);
|
|
322
|
+
}, m = (l) => {
|
|
323
|
+
const { avaman: t } = o(l), { avaman: n } = o(l + 1), { avaman: u } = o(l - 1), s = i(l);
|
|
324
|
+
return s && t < 127 || !(t === 137 && n === 0) && (!s && t < 138 || u === 137 && t === 0);
|
|
325
|
+
}, y = i(e), g = f(e), M = m(e), w = () => {
|
|
326
|
+
const l = g;
|
|
327
|
+
let t = M;
|
|
328
|
+
return l && M && (t = !1), !M && f(e - 1) && m(e - 1) && (t = !0), t;
|
|
329
|
+
}, N = (o(e).harkun - 2) % 7, k = () => {
|
|
330
|
+
let { bodithey: l } = o(e);
|
|
331
|
+
return f(e - 1) && m(e - 1) && (l = (l + 1) % 30), {
|
|
332
|
+
day: l >= 6 ? l - 1 : l,
|
|
333
|
+
month: l >= 6 ? 4 : 5
|
|
334
|
+
};
|
|
335
|
+
}, L = (l) => {
|
|
336
|
+
const t = o(e - 1), n = () => {
|
|
337
|
+
let h = 800 * l + t.kromathopol, r = Math.floor(h / 24350), a = h % 24350, c = Math.floor(a / 811), d = a % 811, v = Math.floor(d / 14) - 3;
|
|
338
|
+
return 1800 * r + 60 * c + v;
|
|
339
|
+
}, u = () => {
|
|
340
|
+
let h = 4800, r = n() - h;
|
|
341
|
+
return n() < h && (r += 1800 * 12), r;
|
|
342
|
+
}, s = () => Math.floor(u() / 1800), _ = () => {
|
|
343
|
+
let h = -1;
|
|
344
|
+
return [0, 1, 2].includes(s()) ? h = s() : [3, 4, 5].includes(s()) ? h = 1800 * 6 - u() : [6, 7, 8].includes(s()) ? h = u() - 1800 * 6 : [9, 10, 11].includes(s()) && (h = 1800 * 11 + 1740 + 60 - u()), {
|
|
345
|
+
reasey: Math.floor(h / 1800),
|
|
346
|
+
angsar: Math.floor(h % 1800 / 60),
|
|
347
|
+
libda: h % 60
|
|
348
|
+
};
|
|
349
|
+
}, Y = () => _().angsar >= 15 ? 2 * _().reasey + 1 : 2 * _().reasey, O = () => _().angsar >= 15 ? 60 * (_().angsar - 15) + _().libda : 60 * _().angsar + _().libda, D = () => {
|
|
350
|
+
let r = ((c) => {
|
|
351
|
+
let d = [35, 32, 27, 22, 13, 5], p = [0, 35, 67, 94, 116, 129];
|
|
352
|
+
switch (c) {
|
|
353
|
+
case 0:
|
|
354
|
+
case 1:
|
|
355
|
+
case 2:
|
|
356
|
+
case 3:
|
|
357
|
+
case 4:
|
|
358
|
+
case 5:
|
|
359
|
+
return {
|
|
360
|
+
multiplicity: d[c],
|
|
361
|
+
chhaya: p[c]
|
|
362
|
+
};
|
|
363
|
+
default:
|
|
364
|
+
return {
|
|
365
|
+
multiplicity: 0,
|
|
366
|
+
chhaya: 134
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
})(Y()), a = Math.floor(O() * r.multiplicity / 900);
|
|
370
|
+
return {
|
|
371
|
+
reasey: 0,
|
|
372
|
+
angsar: Math.floor((a + r.chhaya) / 60),
|
|
373
|
+
libda: (a + r.chhaya) % 60
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
return {
|
|
377
|
+
sunAverageAsLibda: n,
|
|
378
|
+
khan: Y,
|
|
379
|
+
pouichalip: O,
|
|
380
|
+
phol: D,
|
|
381
|
+
sunInaugurationAsLibda: () => {
|
|
382
|
+
let h = 1800 * D().reasey + 60 * D().angsar + D().libda;
|
|
383
|
+
return s() <= 5 ? n() - h : n() + h;
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
}, x = () => (i(e - 1) ? [363, 364, 365, 366] : [362, 363, 364, 365]).map((t) => {
|
|
387
|
+
let n = L(t);
|
|
388
|
+
return {
|
|
389
|
+
sotin: t,
|
|
390
|
+
reasey: Math.floor(n.sunInaugurationAsLibda() / 1800),
|
|
391
|
+
angsar: Math.floor(n.sunInaugurationAsLibda() % 1800 / 60),
|
|
392
|
+
// អង្សាស្មើសូន្យ គីជាថ្ងៃចូលឆ្នាំ, មួយ ឬ ពីរ ថ្ងៃបន្ទាប់ជាថ្ងៃវ័នបត ហើយ ថ្ងៃចុងក្រោយគីឡើងស័ក
|
|
393
|
+
libda: n.sunInaugurationAsLibda() % 60
|
|
394
|
+
};
|
|
395
|
+
}), C = () => {
|
|
396
|
+
let l = x().filter(function(t) {
|
|
397
|
+
return t.angsar === 0;
|
|
398
|
+
});
|
|
399
|
+
if (l.length > 0) {
|
|
400
|
+
let n = 1440 - l[0].libda * 24;
|
|
401
|
+
return {
|
|
402
|
+
hour: Math.floor(n / 60),
|
|
403
|
+
minute: n % 60
|
|
404
|
+
};
|
|
405
|
+
} else
|
|
406
|
+
throw Error(
|
|
407
|
+
"Plugin is facing wrong calculation on new years hour. No sotin with angsar = 0"
|
|
408
|
+
);
|
|
409
|
+
}, A = o(e);
|
|
410
|
+
return {
|
|
411
|
+
jsYear: e,
|
|
412
|
+
harkun: A.harkun,
|
|
413
|
+
kromathopol: A.kromathopol,
|
|
414
|
+
avaman: A.avaman,
|
|
415
|
+
bodithey: A.bodithey,
|
|
416
|
+
has366Days: y,
|
|
417
|
+
isAdhikameas: g,
|
|
418
|
+
isChantreathimeas: M,
|
|
419
|
+
jesthHas30: w(),
|
|
420
|
+
dayLerngSak: N,
|
|
421
|
+
lunarDateLerngSak: k(),
|
|
422
|
+
newYearsDaySotins: x(),
|
|
423
|
+
timeOfNewYear: C()
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
P.extend(gt);
|
|
427
|
+
function rt(e, o) {
|
|
428
|
+
const i = [];
|
|
429
|
+
for (let f = 0; f < o; f++)
|
|
430
|
+
i.push(e.clone().add(f, "day"));
|
|
431
|
+
return i.map((f, m) => {
|
|
432
|
+
let y = "Moha Sangkranta";
|
|
433
|
+
return m === 0 ? y = "Moha Sangkranta" : m === o - 1 ? y = "Veareak Laeung Sak" : y = "Veareak Vanabat", {
|
|
434
|
+
date: f,
|
|
435
|
+
dayName: y
|
|
436
|
+
};
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
function j(e) {
|
|
440
|
+
const o = e + 544 - 1182, i = kt(o), f = b.khNewYearDays[e.toString()], m = f !== void 0 ? f : i.newYearsDaySotins[0].angsar === 0 ? 4 : 3, y = b.khNewYear[e.toString()];
|
|
441
|
+
if (y) {
|
|
442
|
+
const N = P(y, "DD-MM-YYYY HH:mm");
|
|
443
|
+
if (N.isValid())
|
|
444
|
+
return {
|
|
445
|
+
date: N,
|
|
446
|
+
days: m,
|
|
447
|
+
dates: rt(N, m)
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
const g = i.newYearsDaySotins.findIndex((N) => N.angsar === 0);
|
|
451
|
+
if (g === -1)
|
|
452
|
+
throw new Error(
|
|
453
|
+
`Could not calculate Khmer New Year for ${e}: no sotin with angsar === 0`
|
|
454
|
+
);
|
|
455
|
+
const M = 13 + g, w = P(
|
|
456
|
+
`${e}-04-${String(M).padStart(2, "0")}T${String(i.timeOfNewYear.hour).padStart(2, "0")}:${String(i.timeOfNewYear.minute).padStart(2, "0")}`
|
|
457
|
+
);
|
|
458
|
+
return {
|
|
459
|
+
date: w,
|
|
460
|
+
days: m,
|
|
461
|
+
dates: rt(w, m)
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
function wt(e) {
|
|
465
|
+
const o = e.year(), i = j(o).date;
|
|
466
|
+
return e.diff(i) < 0 ? (o + 543 + 4) % 12 : (o + 544 + 4) % 12;
|
|
467
|
+
}
|
|
468
|
+
function Yt(e) {
|
|
469
|
+
const o = e.year(), i = j(o).date;
|
|
470
|
+
return e.diff(i) < 0 ? o + 543 - 1182 : o + 544 - 1182;
|
|
471
|
+
}
|
|
472
|
+
const F = {
|
|
473
|
+
getKhmerNewYear: j,
|
|
474
|
+
getAnimalYear: wt,
|
|
475
|
+
getJolakSakarajYear: Yt
|
|
476
|
+
}, Mt = (e, o, i) => {
|
|
477
|
+
if (i == null || i === "") {
|
|
478
|
+
const f = o.day(), m = e.years.BE, y = b.kh.animalYear[F.getAnimalYear(o)], g = F.getJolakSakarajYear(o) % 10;
|
|
479
|
+
return b.kh.postformat(
|
|
480
|
+
`ថ្ងៃ${b.kh.weekdays[f]} ${e.period.day}${e.period.moon} ខែ${e.month.name} ឆ្នាំ${y} ${b.kh.eraYear[g]} ពុទ្ធសករាជ ${m}`
|
|
481
|
+
);
|
|
482
|
+
} else if (typeof i == "string") {
|
|
483
|
+
const f = {
|
|
484
|
+
W: () => b.kh.weekdays[o.day()],
|
|
485
|
+
w: () => b.kh.weekdaysShort[o.day()],
|
|
486
|
+
d: () => e.period.day,
|
|
487
|
+
D: () => {
|
|
488
|
+
const m = e.period.day;
|
|
489
|
+
return ("" + m).length === 1 ? `០${m}` : m;
|
|
490
|
+
},
|
|
491
|
+
N: () => e.period.moon,
|
|
492
|
+
n: () => e.period.moon === "កើត" ? "ក" : "រ",
|
|
493
|
+
o: () => b.kh.moonDays[e.day],
|
|
494
|
+
m: () => e.month.name,
|
|
495
|
+
M: () => b.kh.months[o.month()],
|
|
496
|
+
a: () => b.kh.animalYear[F.getAnimalYear(o)],
|
|
497
|
+
e: () => b.kh.eraYear[F.getJolakSakarajYear(o) % 10],
|
|
498
|
+
b: () => e.years.BE,
|
|
499
|
+
c: () => o.year(),
|
|
500
|
+
j: () => e.years.JE
|
|
501
|
+
};
|
|
502
|
+
return b.kh.postformat(
|
|
503
|
+
i.replace(
|
|
504
|
+
new RegExp(Object.keys(f).join("|"), "g"),
|
|
505
|
+
(m) => f[m]()
|
|
506
|
+
)
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
return "";
|
|
510
|
+
}, at = {
|
|
511
|
+
formatKhmerDate: Mt,
|
|
512
|
+
khmerNewYearDate: F.getKhmerNewYear
|
|
513
|
+
}, bt = (e, o) => {
|
|
514
|
+
const i = o.prototype;
|
|
515
|
+
i.toKhmerDate = function(f) {
|
|
516
|
+
const m = b.kh.preparse(this.format()), y = _t(m);
|
|
517
|
+
return at.formatKhmerDate(y, this, f);
|
|
518
|
+
}, i.khNewYear = function() {
|
|
519
|
+
return at.khmerNewYearDate(this.year());
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
export {
|
|
523
|
+
bt as default
|
|
524
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(N,F){typeof exports=="object"&&typeof module<"u"?module.exports=F(require("dayjs")):typeof define=="function"&&define.amd?define(["dayjs"],F):(N=typeof globalThis<"u"?globalThis:N||self,N.dayjskh=F(N.dayjs))})(this,(function(N){"use strict";"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_").forEach((e,o)=>o),"ជូត_ឆ្លូវ_ខាល_ថោះ_រោង_ម្សាញ់_មមី_មមែ_វក_រកា_ច_កុរ".split("_").forEach((e,o)=>o),"សំរឹទ្ធិស័ក_ឯកស័ក_ទោស័ក_ត្រីស័ក_ចត្វាស័ក_បញ្ចស័ក_ឆស័ក_សប្តស័ក_អដ្ឋស័ក_នព្វស័ក".split("_").forEach((e,o)=>o),"កើត_រោច".split("_").forEach((e,o)=>o);const b={khNewYear:{1879:"12-04-1879 11:36",1897:"13-04-1897 02:00",2011:"14-04-2011 13:12",2012:"14-04-2012 19:11",2013:"14-04-2013 02:12",2014:"14-04-2014 08:07",2015:"14-04-2015 14:02",2016:"14-04-2016 07:53",2017:"14-04-2017 13:48",2018:"14-04-2018 19:43",2019:"14-04-2019 01:38",2020:"14-04-2020 07:33",2021:"14-04-2021 13:28",2022:"14-04-2022 19:23",2023:"14-04-2023 01:18",2024:"13-04-2024 22:17",2025:"14-04-2025 10:04",2026:"14-04-2026 10:48",2027:"14-04-2027 16:43",2028:"13-04-2028 23:12",2029:"14-04-2029 10:33",2030:"14-04-2030 16:28"},khNewYearDays:{2016:3},kh:(()=>{const e=["១","២","៣","៤","៥","៦","៧","៨","៩","០"],o=[1,2,3,4,5,6,7,8,9,0];return{months:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),monthsShort:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),moonDays:"᧡_᧢_᧣_᧤_᧥_᧦_᧧_᧨_᧩_᧪_᧫_᧬_᧭_᧮_᧯_᧱_᧲_᧳_᧴_᧵_᧶_᧷_᧸_᧹_᧺_᧻_᧼_᧽_᧾_᧿".split("_"),moonStatus:"កើត_រោច".split("_"),moonStatusShort:"ក_រ".split("_"),weekdays:"អាទិត្យ_ចន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍".split("_"),weekdaysShort:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),weekdaysMin:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),lunarMonths:"មិគសិរ_បុស្ស_មាឃ_ផល្គុន_ចេត្រ_ពិសាខ_ជេស្ឋ_អាសាឍ_ស្រាពណ៍_ភទ្របទ_អស្សុជ_កត្តិក_បឋមាសាឍ_ទុតិយាសាឍ".split("_"),animalYear:"ជូត_ឆ្លូវ_ខាល_ថោះ_រោង_ម្សាញ់_មមីរ_មមែ_វក_រកា_ច_កុរ".split("_"),eraYear:"សំរឹទ្ធិស័ក_ឯកស័ក_ទោស័ក_ត្រីស័ក_ចត្វាស័ក_បញ្ចស័ក_ឆស័ក_សប្តស័ក_អដ្ឋស័ក_នព្វស័ក".split("_"),preparse:function(i){return i.replace(/[១២៣៤៥៦៧៨៩០]/g,f=>o[e.indexOf(f)])},postformat:function(i){return i.replace(/[1234567890]/g,f=>e[o.indexOf(Number(f))])}}})()};function st(e=N()){const o=r=>(r*292207+373)%800,i=r=>Math.floor((r*292207+373)/800)+1,f=r=>(11*i(r)+650)%692,m=r=>800-o(r)<=207;function p(r){const a=i(r);return(a+Math.floor((11*a+650)/692))%30}function g(r){let a=0,c=1333,d=r.year()-638;if(c>d){let y=c;c=d,d=y}for(;c<d;)a+=D(c++);return a}function D(r){return w(r)?384:E(r)?355:354}function w(r){const a=p(r),c=p(r+1);return a>24||a<6||a===24&&c===6||a===25&&c===5}function O(r){const a=k(r);return{month:3+ +(a>=6&&a<=29),day:a}}function k(r){const a=p(r),c=w(r-1);return!c||c&&!A(r-1)?a<6?a+1:a:a+1}function E(r){let a=A(r);return w(r)&&a&&(a=!1),a}function A(r){const a=f(r),c=f(r+1),d=m(r);let y=d&&a<127;return d||(a===137&&c===0?y=!1:a<138&&(y=!0)),y||(y=A(r-1)&&w(r-1)),y}function C(r){return Math.abs(Math.round((r.valueOf()-286596e5)/864e5))}function L(r){const a=w(r),c=E(r),d=[];for(let y=0;y<12+Number(a);y++){let v=y;a&&v>=8&&v--,d.push(29+ +(v%2!=0)+(v===6&&c?1:0))}return d}typeof e=="string"&&(e=N(e)),e=e.subtract(7,"hour");const l=e.year();let t=l-638,n=Math.abs(C(e)-g(e))+1;const u=l+543+ +(n>162),s=D(t);n>s&&(n-=s,t++);let _=0;const Y=L(t);for(const r of Y){if(n<=r)break;n-=r,_++}const $=O(t-1),M=t-1-+($.month>_||$.month===_&&$.day>e.date()),S=["មិគសិរ","បុស្ស","មាឃ","ផល្គុន","ចេត្រ","ពិសាខ","ជេស្ឋ","អាសាឍ","បឋមាសាឍ","ទុតិយាសាឍ","ស្រាពណ៍","ភទ្របទ","អស្សុជ","កត្តិក"].filter((r,a)=>Y.length==12?a!=8&&a!=9:a!=7),h=["ជូត","ឆ្លូវ","ខាល","ថោះ","រោង","ម្សាញ់","មមីរ","មមែ","វក","រកា","ច","កុរ"];return{day:n,period:{day:(n-1)%15+1,moon:n>15?"រោច":"កើត"},zodiac:h[((M+1)%12+10)%12],years:{JE:M,CE:l,BE:u},length:s,monthLength:Y[_],month:{name:S[_],index:_},months:S}}function it(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z={exports:{}},ut=Z.exports,et;function lt(){return et||(et=1,(function(e,o){(function(i,f){e.exports=f()})(ut,(function(){var i={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},f=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,m=/\d/,p=/\d\d/,g=/\d\d?/,D=/\d*[^-_:/,()\s\d]+/,w={},O=function(t){return(t=+t)+(t>68?1900:2e3)},k=function(t){return function(n){this[t]=+n}},E=[/[+-]\d\d:?(\d\d)?|Z/,function(t){(this.zone||(this.zone={})).offset=(function(n){if(!n||n==="Z")return 0;var u=n.match(/([+-]|\d\d)/g),s=60*u[1]+(+u[2]||0);return s===0?0:u[0]==="+"?-s:s})(t)}],A=function(t){var n=w[t];return n&&(n.indexOf?n:n.s.concat(n.f))},C=function(t,n){var u,s=w.meridiem;if(s){for(var _=1;_<=24;_+=1)if(t.indexOf(s(_,0,n))>-1){u=_>12;break}}else u=t===(n?"pm":"PM");return u},L={A:[D,function(t){this.afternoon=C(t,!1)}],a:[D,function(t){this.afternoon=C(t,!0)}],Q:[m,function(t){this.month=3*(t-1)+1}],S:[m,function(t){this.milliseconds=100*+t}],SS:[p,function(t){this.milliseconds=10*+t}],SSS:[/\d{3}/,function(t){this.milliseconds=+t}],s:[g,k("seconds")],ss:[g,k("seconds")],m:[g,k("minutes")],mm:[g,k("minutes")],H:[g,k("hours")],h:[g,k("hours")],HH:[g,k("hours")],hh:[g,k("hours")],D:[g,k("day")],DD:[p,k("day")],Do:[D,function(t){var n=w.ordinal,u=t.match(/\d+/);if(this.day=u[0],n)for(var s=1;s<=31;s+=1)n(s).replace(/\[|\]/g,"")===t&&(this.day=s)}],w:[g,k("week")],ww:[p,k("week")],M:[g,k("month")],MM:[p,k("month")],MMM:[D,function(t){var n=A("months"),u=(A("monthsShort")||n.map((function(s){return s.slice(0,3)}))).indexOf(t)+1;if(u<1)throw new Error;this.month=u%12||u}],MMMM:[D,function(t){var n=A("months").indexOf(t)+1;if(n<1)throw new Error;this.month=n%12||n}],Y:[/[+-]?\d+/,k("year")],YY:[p,function(t){this.year=O(t)}],YYYY:[/\d{4}/,k("year")],Z:E,ZZ:E};function l(t){var n,u;n=t,u=w&&w.formats;for(var s=(t=n.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(r,a,c){var d=c&&c.toUpperCase();return a||u[c]||i[c]||u[d].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(y,v,I){return v||I.slice(1)}))}))).match(f),_=s.length,Y=0;Y<_;Y+=1){var $=s[Y],M=L[$],S=M&&M[0],h=M&&M[1];s[Y]=h?{regex:S,parser:h}:$.replace(/^\[|\]$/g,"")}return function(r){for(var a={},c=0,d=0;c<_;c+=1){var y=s[c];if(typeof y=="string")d+=y.length;else{var v=y.regex,I=y.parser,z=r.slice(d),H=v.exec(z)[0];I.call(a,H),r=r.replace(H,"")}}return(function(P){var J=P.afternoon;if(J!==void 0){var x=P.hours;J?x<12&&(P.hours+=12):x===12&&(P.hours=0),delete P.afternoon}})(a),a}}return function(t,n,u){u.p.customParseFormat=!0,t&&t.parseTwoDigitYear&&(O=t.parseTwoDigitYear);var s=n.prototype,_=s.parse;s.parse=function(Y){var $=Y.date,M=Y.utc,S=Y.args;this.$u=M;var h=S[1];if(typeof h=="string"){var r=S[2]===!0,a=S[3]===!0,c=r||a,d=S[2];a&&(d=S[2]),w=this.$locale(),!r&&d&&(w=u.Ls[d]),this.$d=(function(z,H,P,J){try{if(["x","X"].indexOf(H)>-1)return new Date((H==="X"?1e3:1)*z);var x=l(H)(z),U=x.year,V=x.month,dt=x.day,pt=x.hours,yt=x.minutes,gt=x.seconds,kt=x.milliseconds,at=x.zone,ot=x.week,Q=new Date,W=dt||(U||V?1:Q.getDate()),X=U||Q.getFullYear(),q=0;U&&!V||(q=V>0?V-1:Q.getMonth());var R,K=pt||0,G=yt||0,j=gt||0,tt=kt||0;return at?new Date(Date.UTC(X,q,W,K,G,j,tt+60*at.offset*1e3)):P?new Date(Date.UTC(X,q,W,K,G,j,tt)):(R=new Date(X,q,W,K,G,j,tt),ot&&(R=J(R).week(ot).toDate()),R)}catch{return new Date("")}})($,h,M,u),this.init(),d&&d!==!0&&(this.$L=this.locale(d).$L),c&&$!=this.format(h)&&(this.$d=new Date("")),w={}}else if(h instanceof Array)for(var y=h.length,v=1;v<=y;v+=1){S[1]=h[v-1];var I=u.apply(this,S);if(I.isValid()){this.$d=I.$d,this.$L=I.$L,this.init();break}v===y&&(this.$d=new Date(""))}else _.call(this,Y)}}}))})(Z)),Z.exports}var ct=lt();const ft=it(ct);function ht(e=N().year()){arguments.length===0?e=N().year():e=arguments[0];const o=l=>{let t=292207*l+373,n=Math.floor(t/800)+1,u=800-t%800,s=11*n+650,_=s%692,Y=(n+Math.floor(s/692))%30;return{harkun:n,kromathopol:u,avaman:_,bodithey:Y}},i=l=>{const{kromathopol:t}=o(l);return t<=207},f=l=>{const{bodithey:t}=o(l),{bodithey:n}=o(l+1);return!(t===25&&n===5)&&(t>24||n<6||t===24&&n===6)},m=l=>{const{avaman:t}=o(l),{avaman:n}=o(l+1),{avaman:u}=o(l-1),s=i(l);return s&&t<127||!(t===137&&n===0)&&(!s&&t<138||u===137&&t===0)},p=i(e),g=f(e),D=m(e),w=()=>{const l=g;let t=D;return l&&D&&(t=!1),!D&&f(e-1)&&m(e-1)&&(t=!0),t},O=(o(e).harkun-2)%7,k=()=>{let{bodithey:l}=o(e);return f(e-1)&&m(e-1)&&(l=(l+1)%30),{day:l>=6?l-1:l,month:l>=6?4:5}},E=l=>{const t=o(e-1),n=()=>{let h=800*l+t.kromathopol,r=Math.floor(h/24350),a=h%24350,c=Math.floor(a/811),d=a%811,v=Math.floor(d/14)-3;return 1800*r+60*c+v},u=()=>{let h=4800,r=n()-h;return n()<h&&(r+=1800*12),r},s=()=>Math.floor(u()/1800),_=()=>{let h=-1;return[0,1,2].includes(s())?h=s():[3,4,5].includes(s())?h=1800*6-u():[6,7,8].includes(s())?h=u()-1800*6:[9,10,11].includes(s())&&(h=1800*11+1740+60-u()),{reasey:Math.floor(h/1800),angsar:Math.floor(h%1800/60),libda:h%60}},Y=()=>_().angsar>=15?2*_().reasey+1:2*_().reasey,$=()=>_().angsar>=15?60*(_().angsar-15)+_().libda:60*_().angsar+_().libda,M=()=>{let r=(c=>{let d=[35,32,27,22,13,5],y=[0,35,67,94,116,129];switch(c){case 0:case 1:case 2:case 3:case 4:case 5:return{multiplicity:d[c],chhaya:y[c]};default:return{multiplicity:0,chhaya:134}}})(Y()),a=Math.floor($()*r.multiplicity/900);return{reasey:0,angsar:Math.floor((a+r.chhaya)/60),libda:(a+r.chhaya)%60}};return{sunAverageAsLibda:n,khan:Y,pouichalip:$,phol:M,sunInaugurationAsLibda:()=>{let h=1800*M().reasey+60*M().angsar+M().libda;return s()<=5?n()-h:n()+h}}},A=()=>(i(e-1)?[363,364,365,366]:[362,363,364,365]).map(t=>{let n=E(t);return{sotin:t,reasey:Math.floor(n.sunInaugurationAsLibda()/1800),angsar:Math.floor(n.sunInaugurationAsLibda()%1800/60),libda:n.sunInaugurationAsLibda()%60}}),C=()=>{let l=A().filter(function(t){return t.angsar===0});if(l.length>0){let n=1440-l[0].libda*24;return{hour:Math.floor(n/60),minute:n%60}}else throw Error("Plugin is facing wrong calculation on new years hour. No sotin with angsar = 0")},L=o(e);return{jsYear:e,harkun:L.harkun,kromathopol:L.kromathopol,avaman:L.avaman,bodithey:L.bodithey,has366Days:p,isAdhikameas:g,isChantreathimeas:D,jesthHas30:w(),dayLerngSak:O,lunarDateLerngSak:k(),newYearsDaySotins:A(),timeOfNewYear:C()}}N.extend(ft);function nt(e,o){const i=[];for(let f=0;f<o;f++)i.push(e.clone().add(f,"day"));return i.map((f,m)=>{let p="Moha Sangkranta";return m===0?p="Moha Sangkranta":m===o-1?p="Veareak Laeung Sak":p="Veareak Vanabat",{date:f,dayName:p}})}function B(e){const o=e+544-1182,i=ht(o),f=b.khNewYearDays[e.toString()],m=f!==void 0?f:i.newYearsDaySotins[0].angsar===0?4:3,p=b.khNewYear[e.toString()];if(p){const O=N(p,"DD-MM-YYYY HH:mm");if(O.isValid())return{date:O,days:m,dates:nt(O,m)}}const g=i.newYearsDaySotins.findIndex(O=>O.angsar===0);if(g===-1)throw new Error(`Could not calculate Khmer New Year for ${e}: no sotin with angsar === 0`);const D=13+g,w=N(`${e}-04-${String(D).padStart(2,"0")}T${String(i.timeOfNewYear.hour).padStart(2,"0")}:${String(i.timeOfNewYear.minute).padStart(2,"0")}`);return{date:w,days:m,dates:nt(w,m)}}function _t(e){const o=e.year(),i=B(o).date;return e.diff(i)<0?(o+543+4)%12:(o+544+4)%12}function mt(e){const o=e.year(),i=B(o).date;return e.diff(i)<0?o+543-1182:o+544-1182}const T={getKhmerNewYear:B,getAnimalYear:_t,getJolakSakarajYear:mt},rt={formatKhmerDate:(e,o,i)=>{if(i==null||i===""){const f=o.day(),m=e.years.BE,p=b.kh.animalYear[T.getAnimalYear(o)],g=T.getJolakSakarajYear(o)%10;return b.kh.postformat(`ថ្ងៃ${b.kh.weekdays[f]} ${e.period.day}${e.period.moon} ខែ${e.month.name} ឆ្នាំ${p} ${b.kh.eraYear[g]} ពុទ្ធសករាជ ${m}`)}else if(typeof i=="string"){const f={W:()=>b.kh.weekdays[o.day()],w:()=>b.kh.weekdaysShort[o.day()],d:()=>e.period.day,D:()=>{const m=e.period.day;return(""+m).length===1?`០${m}`:m},N:()=>e.period.moon,n:()=>e.period.moon==="កើត"?"ក":"រ",o:()=>b.kh.moonDays[e.day],m:()=>e.month.name,M:()=>b.kh.months[o.month()],a:()=>b.kh.animalYear[T.getAnimalYear(o)],e:()=>b.kh.eraYear[T.getJolakSakarajYear(o)%10],b:()=>e.years.BE,c:()=>o.year(),j:()=>e.years.JE};return b.kh.postformat(i.replace(new RegExp(Object.keys(f).join("|"),"g"),m=>f[m]()))}return""},khmerNewYearDate:T.getKhmerNewYear};return(e,o)=>{const i=o.prototype;i.toKhmerDate=function(f){const m=b.kh.preparse(this.format()),p=st(m);return rt.formatKhmerDate(p,this,f)},i.khNewYear=function(){return rt.khmerNewYearDate(this.year())}}}));
|
package/package.json
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dayjskh",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"types": "./types/index.d.ts",
|
|
6
5
|
"description": "Khmer Lunar date Plugin for Day.js",
|
|
7
|
-
"
|
|
6
|
+
"main": "./dist/dayjskh.umd.js",
|
|
7
|
+
"module": "./dist/dayjskh.es.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./types/index.d.ts",
|
|
12
|
+
"import": "./dist/dayjskh.es.js",
|
|
13
|
+
"require": "./dist/dayjskh.umd.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"types"
|
|
19
|
+
],
|
|
8
20
|
"scripts": {
|
|
9
21
|
"dev": "vite",
|
|
10
22
|
"build": "tsc -p tsconfig.json && vite build",
|
|
11
|
-
"preview": "vite preview"
|
|
23
|
+
"preview": "vite preview",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
12
25
|
},
|
|
13
26
|
"repository": {
|
|
14
27
|
"type": "git",
|
|
@@ -17,12 +30,12 @@
|
|
|
17
30
|
"author": "chanthorn",
|
|
18
31
|
"license": "MIT",
|
|
19
32
|
"devDependencies": {
|
|
20
|
-
"@types/node": "^
|
|
21
|
-
"prettier": "3.
|
|
22
|
-
"typescript": "^5.
|
|
23
|
-
"vite": "^
|
|
33
|
+
"@types/node": "^25.2.2",
|
|
34
|
+
"prettier": "3.8.1",
|
|
35
|
+
"typescript": "^5.9.3",
|
|
36
|
+
"vite": "^7.3.1"
|
|
24
37
|
},
|
|
25
38
|
"dependencies": {
|
|
26
|
-
"dayjs": "^1.11.
|
|
39
|
+
"dayjs": "^1.11.19"
|
|
27
40
|
}
|
|
28
|
-
}
|
|
41
|
+
}
|
package/types/index.d.ts
CHANGED
package/.editorconfig
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*]
|
|
4
|
-
charset = utf-8
|
|
5
|
-
end_of_line = lf
|
|
6
|
-
insert_final_newline = true
|
|
7
|
-
indent_style = space
|
|
8
|
-
indent_size = 4
|
|
9
|
-
trim_trailing_whitespace = true
|
|
10
|
-
|
|
11
|
-
[*.{json,vue,js,jsx,ts,tsx,css,scss,html}]
|
|
12
|
-
indent_size = 2
|
|
13
|
-
[*.md]
|
|
14
|
-
trim_trailing_whitespace = false
|
|
15
|
-
|
|
16
|
-
[*.{yml,yaml}]
|
|
17
|
-
indent_size = 2
|
|
18
|
-
|
|
19
|
-
[docker-compose.yml]
|
|
20
|
-
indent_size = 4
|
package/.prettierrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|