@thyrith/momentkh 3.0.0 → 3.0.2
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.md +134 -114
- package/dist/momentkh.d.ts +65 -36
- package/dist/momentkh.d.ts.map +1 -1
- package/dist/momentkh.js +152 -112
- package/momentkh.js +1117 -11
- package/momentkh.ts +169 -125
- package/package.json +3 -2
package/dist/momentkh.d.ts
CHANGED
|
@@ -16,20 +16,20 @@ export declare enum MoonPhase {
|
|
|
16
16
|
Waning = 1
|
|
17
17
|
}
|
|
18
18
|
export declare enum MonthIndex {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Migasir = 0,// មិគសិរ
|
|
20
|
+
Boss = 1,// បុស្ស
|
|
21
21
|
Meak = 2,// មាឃ
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
Phalkun = 3,// ផល្គុន
|
|
23
|
+
Cheit = 4,// ចេត្រ
|
|
24
|
+
Pisakh = 5,// ពិសាខ
|
|
25
25
|
Jesth = 6,// ជេស្ឋ
|
|
26
|
-
|
|
26
|
+
Asadh = 7,// អាសាឍ
|
|
27
27
|
Srap = 8,// ស្រាពណ៍
|
|
28
|
-
|
|
28
|
+
Phatrabot = 9,// ភទ្របទ
|
|
29
29
|
Assoch = 10,// អស្សុជ
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
Kadeuk = 11,// កត្ដិក
|
|
31
|
+
Pathamasadh = 12,// បឋមាសាឍ
|
|
32
|
+
Tutiyasadh = 13
|
|
33
33
|
}
|
|
34
34
|
export declare enum AnimalYear {
|
|
35
35
|
Chhut = 0,// ជូត - Rat
|
|
@@ -45,17 +45,17 @@ export declare enum AnimalYear {
|
|
|
45
45
|
Cho = 10,// ច - Dog
|
|
46
46
|
Kor = 11
|
|
47
47
|
}
|
|
48
|
-
export declare enum
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
export declare enum Sak {
|
|
49
|
+
SamridhiSak = 0,// សំរឹទ្ធិស័ក
|
|
50
|
+
AekSak = 1,// ឯកស័ក
|
|
51
|
+
ToSak = 2,// ទោស័ក
|
|
52
|
+
TreiSak = 3,// ត្រីស័ក
|
|
53
|
+
ChattvaSak = 4,// ចត្វាស័ក
|
|
54
|
+
PanchaSak = 5,// បញ្ចស័ក
|
|
55
|
+
ChhaSak = 6,// ឆស័ក
|
|
56
|
+
SappaSak = 7,// សប្តស័ក
|
|
57
|
+
AtthaSak = 8,// អដ្ឋស័ក
|
|
58
|
+
NappaSak = 9
|
|
59
59
|
}
|
|
60
60
|
export declare enum DayOfWeek {
|
|
61
61
|
Sunday = 0,// អាទិត្យ
|
|
@@ -85,8 +85,8 @@ export interface KhmerDateInfo {
|
|
|
85
85
|
jsYear: number;
|
|
86
86
|
animalYear: AnimalYear;
|
|
87
87
|
animalYearName: string;
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
sak: Sak;
|
|
89
|
+
sakName: string;
|
|
90
90
|
dayOfWeek: DayOfWeek;
|
|
91
91
|
dayOfWeekName: string;
|
|
92
92
|
}
|
|
@@ -138,10 +138,18 @@ export interface Constants {
|
|
|
138
138
|
LunarMonths: Record<string, number>;
|
|
139
139
|
LunarMonthNames: string[];
|
|
140
140
|
SolarMonthNames: string[];
|
|
141
|
+
SolarMonthAbbreviationNames: string[];
|
|
142
|
+
LunarMonthAbbreviationNames: string[];
|
|
141
143
|
AnimalYearNames: string[];
|
|
142
|
-
|
|
144
|
+
AnimalYearEmojis: string[];
|
|
145
|
+
SakNames: string[];
|
|
143
146
|
WeekdayNames: string[];
|
|
144
|
-
|
|
147
|
+
WeekdayNamesShort: string[];
|
|
148
|
+
MoonPhaseNames: string[];
|
|
149
|
+
MoonPhaseShort: string[];
|
|
150
|
+
MoonDaySymbols: string[];
|
|
151
|
+
KhmerNumerals: Record<string, string>;
|
|
152
|
+
khNewYearMoments: Record<string, string>;
|
|
145
153
|
}
|
|
146
154
|
declare class KhmerDate {
|
|
147
155
|
day: number;
|
|
@@ -155,27 +163,48 @@ declare class KhmerDate {
|
|
|
155
163
|
subtractDays(count: number): KhmerDate;
|
|
156
164
|
toString(): string;
|
|
157
165
|
}
|
|
158
|
-
export declare
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
166
|
+
export declare function fromGregorian(year: number, month: number, day: number, hour?: number, minute?: number, second?: number): KhmerConversionResult;
|
|
167
|
+
export declare function fromKhmer(day: number, moonPhase: MoonPhase | number, monthIndex: MonthIndex | number, beYear: number): GregorianDate;
|
|
168
|
+
export declare function getNewYear(ceYear: number): NewYearInfo;
|
|
169
|
+
export declare function format(khmerData: KhmerConversionResult, formatString?: string): string;
|
|
170
|
+
export declare function fromDate(date: Date): KhmerConversionResult;
|
|
171
|
+
export declare function toDate(day: number, moonPhase: MoonPhase | number, monthIndex: MonthIndex | number, beYear: number): Date;
|
|
172
|
+
export declare const constants: {
|
|
173
|
+
LunarMonths: Record<string, number>;
|
|
174
|
+
LunarMonthNames: string[];
|
|
175
|
+
SolarMonthNames: string[];
|
|
176
|
+
SolarMonthAbbreviationNames: string[];
|
|
177
|
+
LunarMonthAbbreviationNames: string[];
|
|
178
|
+
AnimalYearNames: string[];
|
|
179
|
+
AnimalYearEmojis: string[];
|
|
180
|
+
SakNames: string[];
|
|
181
|
+
WeekdayNames: string[];
|
|
182
|
+
MoonPhaseNames: string[];
|
|
183
|
+
};
|
|
184
|
+
declare const _default: {
|
|
185
|
+
fromGregorian: typeof fromGregorian;
|
|
186
|
+
fromKhmer: typeof fromKhmer;
|
|
187
|
+
getNewYear: typeof getNewYear;
|
|
188
|
+
format: typeof format;
|
|
189
|
+
fromDate: typeof fromDate;
|
|
190
|
+
toDate: typeof toDate;
|
|
165
191
|
constants: {
|
|
166
192
|
LunarMonths: Record<string, number>;
|
|
167
193
|
LunarMonthNames: string[];
|
|
168
194
|
SolarMonthNames: string[];
|
|
195
|
+
SolarMonthAbbreviationNames: string[];
|
|
196
|
+
LunarMonthAbbreviationNames: string[];
|
|
169
197
|
AnimalYearNames: string[];
|
|
170
|
-
|
|
198
|
+
AnimalYearEmojis: string[];
|
|
199
|
+
SakNames: string[];
|
|
171
200
|
WeekdayNames: string[];
|
|
172
|
-
|
|
201
|
+
MoonPhaseNames: string[];
|
|
173
202
|
};
|
|
174
203
|
MoonPhase: typeof MoonPhase;
|
|
175
204
|
MonthIndex: typeof MonthIndex;
|
|
176
205
|
AnimalYear: typeof AnimalYear;
|
|
177
|
-
|
|
206
|
+
Sak: typeof Sak;
|
|
178
207
|
DayOfWeek: typeof DayOfWeek;
|
|
179
208
|
};
|
|
180
|
-
export default
|
|
209
|
+
export default _default;
|
|
181
210
|
//# sourceMappingURL=momentkh.d.ts.map
|
package/dist/momentkh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"momentkh.d.ts","sourceRoot":"","sources":["../momentkh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,oBAAY,SAAS;IACnB,MAAM,IAAI,CAAG,MAAM;IACnB,MAAM,IAAI;CACX;AAED,oBAAY,UAAU;IACpB,OAAO,IAAI,CAAO,SAAS;IAC3B,
|
|
1
|
+
{"version":3,"file":"momentkh.d.ts","sourceRoot":"","sources":["../momentkh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,oBAAY,SAAS;IACnB,MAAM,IAAI,CAAG,MAAM;IACnB,MAAM,IAAI;CACX;AAED,oBAAY,UAAU;IACpB,OAAO,IAAI,CAAO,SAAS;IAC3B,IAAI,IAAI,CAAW,QAAQ;IAC3B,IAAI,IAAI,CAAU,MAAM;IACxB,OAAO,IAAI,CAAO,SAAS;IAC3B,KAAK,IAAI,CAAS,QAAQ;IAC1B,MAAM,IAAI,CAAQ,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js
CHANGED
|
@@ -13,7 +13,13 @@
|
|
|
13
13
|
* @license MIT
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.constants = exports.DayOfWeek = exports.Sak = exports.AnimalYear = exports.MonthIndex = exports.MoonPhase = void 0;
|
|
17
|
+
exports.fromGregorian = fromGregorian;
|
|
18
|
+
exports.fromKhmer = fromKhmer;
|
|
19
|
+
exports.getNewYear = getNewYear;
|
|
20
|
+
exports.format = format;
|
|
21
|
+
exports.fromDate = fromDate;
|
|
22
|
+
exports.toDate = toDate;
|
|
17
23
|
// ============================================================================
|
|
18
24
|
// Type Definitions
|
|
19
25
|
// ============================================================================
|
|
@@ -25,20 +31,20 @@ var MoonPhase;
|
|
|
25
31
|
})(MoonPhase || (exports.MoonPhase = MoonPhase = {}));
|
|
26
32
|
var MonthIndex;
|
|
27
33
|
(function (MonthIndex) {
|
|
28
|
-
MonthIndex[MonthIndex["
|
|
29
|
-
MonthIndex[MonthIndex["
|
|
34
|
+
MonthIndex[MonthIndex["Migasir"] = 0] = "Migasir";
|
|
35
|
+
MonthIndex[MonthIndex["Boss"] = 1] = "Boss";
|
|
30
36
|
MonthIndex[MonthIndex["Meak"] = 2] = "Meak";
|
|
31
|
-
MonthIndex[MonthIndex["
|
|
32
|
-
MonthIndex[MonthIndex["
|
|
33
|
-
MonthIndex[MonthIndex["
|
|
37
|
+
MonthIndex[MonthIndex["Phalkun"] = 3] = "Phalkun";
|
|
38
|
+
MonthIndex[MonthIndex["Cheit"] = 4] = "Cheit";
|
|
39
|
+
MonthIndex[MonthIndex["Pisakh"] = 5] = "Pisakh";
|
|
34
40
|
MonthIndex[MonthIndex["Jesth"] = 6] = "Jesth";
|
|
35
|
-
MonthIndex[MonthIndex["
|
|
41
|
+
MonthIndex[MonthIndex["Asadh"] = 7] = "Asadh";
|
|
36
42
|
MonthIndex[MonthIndex["Srap"] = 8] = "Srap";
|
|
37
|
-
MonthIndex[MonthIndex["
|
|
43
|
+
MonthIndex[MonthIndex["Phatrabot"] = 9] = "Phatrabot";
|
|
38
44
|
MonthIndex[MonthIndex["Assoch"] = 10] = "Assoch";
|
|
39
|
-
MonthIndex[MonthIndex["
|
|
40
|
-
MonthIndex[MonthIndex["
|
|
41
|
-
MonthIndex[MonthIndex["
|
|
45
|
+
MonthIndex[MonthIndex["Kadeuk"] = 11] = "Kadeuk";
|
|
46
|
+
MonthIndex[MonthIndex["Pathamasadh"] = 12] = "Pathamasadh";
|
|
47
|
+
MonthIndex[MonthIndex["Tutiyasadh"] = 13] = "Tutiyasadh"; // ទុតិយាសាឍ
|
|
42
48
|
})(MonthIndex || (exports.MonthIndex = MonthIndex = {}));
|
|
43
49
|
var AnimalYear;
|
|
44
50
|
(function (AnimalYear) {
|
|
@@ -55,19 +61,19 @@ var AnimalYear;
|
|
|
55
61
|
AnimalYear[AnimalYear["Cho"] = 10] = "Cho";
|
|
56
62
|
AnimalYear[AnimalYear["Kor"] = 11] = "Kor"; // កុរ - Pig
|
|
57
63
|
})(AnimalYear || (exports.AnimalYear = AnimalYear = {}));
|
|
58
|
-
var
|
|
59
|
-
(function (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})(
|
|
64
|
+
var Sak;
|
|
65
|
+
(function (Sak) {
|
|
66
|
+
Sak[Sak["SamridhiSak"] = 0] = "SamridhiSak";
|
|
67
|
+
Sak[Sak["AekSak"] = 1] = "AekSak";
|
|
68
|
+
Sak[Sak["ToSak"] = 2] = "ToSak";
|
|
69
|
+
Sak[Sak["TreiSak"] = 3] = "TreiSak";
|
|
70
|
+
Sak[Sak["ChattvaSak"] = 4] = "ChattvaSak";
|
|
71
|
+
Sak[Sak["PanchaSak"] = 5] = "PanchaSak";
|
|
72
|
+
Sak[Sak["ChhaSak"] = 6] = "ChhaSak";
|
|
73
|
+
Sak[Sak["SappaSak"] = 7] = "SappaSak";
|
|
74
|
+
Sak[Sak["AtthaSak"] = 8] = "AtthaSak";
|
|
75
|
+
Sak[Sak["NappaSak"] = 9] = "NappaSak"; // នព្វស័ក
|
|
76
|
+
})(Sak || (exports.Sak = Sak = {}));
|
|
71
77
|
var DayOfWeek;
|
|
72
78
|
(function (DayOfWeek) {
|
|
73
79
|
DayOfWeek[DayOfWeek["Sunday"] = 0] = "Sunday";
|
|
@@ -96,11 +102,24 @@ const SolarMonthNames = [
|
|
|
96
102
|
'មករា', 'កុម្ភៈ', 'មីនា', 'មេសា', 'ឧសភា', 'មិថុនា',
|
|
97
103
|
'កក្កដា', 'សីហា', 'កញ្ញា', 'តុលា', 'វិច្ឆិកា', 'ធ្នូ'
|
|
98
104
|
];
|
|
105
|
+
const SolarMonthAbbreviationNames = [
|
|
106
|
+
'មក', 'កម', 'មន', 'មស', 'ឧស', 'មថ',
|
|
107
|
+
'កដ', 'សហ', 'កញ', 'តល', 'វក', 'ធន'
|
|
108
|
+
];
|
|
109
|
+
const LunarMonthAbbreviationNames = [
|
|
110
|
+
'មិ', 'បុ', 'មា', 'ផល', 'ចេ', 'ពិ',
|
|
111
|
+
'ជេ', 'អា', 'ស្រ', 'ភ', 'អ', 'ក',
|
|
112
|
+
'បឋ', 'ទុតិ'
|
|
113
|
+
];
|
|
99
114
|
const AnimalYearNames = [
|
|
100
115
|
'ជូត', 'ឆ្លូវ', 'ខាល', 'ថោះ', 'រោង', 'ម្សាញ់',
|
|
101
116
|
'មមី', 'មមែ', 'វក', 'រកា', 'ច', 'កុរ'
|
|
102
117
|
];
|
|
103
|
-
const
|
|
118
|
+
const AnimalYearEmojis = [
|
|
119
|
+
'🐀', '🐂', '🐅', '🐇', '🐉', '🐍',
|
|
120
|
+
'🐎', '🐐', '🐒', '🐓', '🐕', '🐖'
|
|
121
|
+
];
|
|
122
|
+
const SakNames = [
|
|
104
123
|
'សំរឹទ្ធិស័ក', 'ឯកស័ក', 'ទោស័ក', 'ត្រីស័ក', 'ចត្វាស័ក',
|
|
105
124
|
'បញ្ចស័ក', 'ឆស័ក', 'សប្តស័ក', 'អដ្ឋស័ក', 'នព្វស័ក'
|
|
106
125
|
];
|
|
@@ -108,8 +127,8 @@ const WeekdayNames = [
|
|
|
108
127
|
'អាទិត្យ', 'ចន្ទ', 'អង្គារ', 'ពុធ', 'ព្រហស្បតិ៍', 'សុក្រ', 'សៅរ៍'
|
|
109
128
|
];
|
|
110
129
|
const WeekdayNamesShort = ['អា', 'ច', 'អ', 'ព', 'ព្រ', 'សុ', 'ស'];
|
|
111
|
-
const
|
|
112
|
-
const
|
|
130
|
+
const MoonPhaseNames = ['កើត', 'រោច'];
|
|
131
|
+
const MoonPhaseShort = ['ក', 'រ'];
|
|
113
132
|
const MoonDaySymbols = [
|
|
114
133
|
'᧡', '᧢', '᧣', '᧤', '᧥', '᧦', '᧧', '᧨', '᧩', '᧪',
|
|
115
134
|
'᧫', '᧬', '᧭', '᧮', '᧯', '᧱', '᧲', '᧳', '᧴', '᧵',
|
|
@@ -372,7 +391,7 @@ function getNumberOfDaysInKhmerMonth(monthIndex, beYear) {
|
|
|
372
391
|
if (idx === MonthIndex.Jesth && leapType === 2) { // ជេស្ឋ with leap day
|
|
373
392
|
return 30;
|
|
374
393
|
}
|
|
375
|
-
if (idx === MonthIndex.
|
|
394
|
+
if (idx === MonthIndex.Pathamasadh || idx === MonthIndex.Tutiyasadh) { // បឋមាសាឍ, ទុតិយាសាឍ
|
|
376
395
|
return leapType === 1 ? 30 : 0;
|
|
377
396
|
}
|
|
378
397
|
// Alternating pattern: even months = 29 days, odd months = 30 days
|
|
@@ -391,26 +410,26 @@ function nextMonthOf(monthIndex, beYear) {
|
|
|
391
410
|
const leapType = getLeapType(beYear);
|
|
392
411
|
const idx = typeof monthIndex === 'number' ? monthIndex : monthIndex;
|
|
393
412
|
if (idx === MonthIndex.Jesth && leapType === 1) { // ជេស្ឋ in leap month year
|
|
394
|
-
return MonthIndex.
|
|
413
|
+
return MonthIndex.Pathamasadh; // បឋមាសាឍ
|
|
395
414
|
}
|
|
396
|
-
if (idx === MonthIndex.
|
|
397
|
-
return MonthIndex.
|
|
398
|
-
if (idx === MonthIndex.
|
|
399
|
-
return MonthIndex.
|
|
400
|
-
if (idx === MonthIndex.
|
|
415
|
+
if (idx === MonthIndex.Kadeuk)
|
|
416
|
+
return MonthIndex.Migasir; // កត្ដិក -> មិគសិរ
|
|
417
|
+
if (idx === MonthIndex.Pathamasadh)
|
|
418
|
+
return MonthIndex.Tutiyasadh; // បឋមាសាឍ -> ទុតិយាសាឍ
|
|
419
|
+
if (idx === MonthIndex.Tutiyasadh)
|
|
401
420
|
return MonthIndex.Srap; // ទុតិយាសាឍ -> ស្រាពណ៍
|
|
402
421
|
return (idx + 1);
|
|
403
422
|
}
|
|
404
423
|
function previousMonthOf(monthIndex, beYear) {
|
|
405
424
|
const leapType = getLeapType(beYear);
|
|
406
425
|
const idx = typeof monthIndex === 'number' ? monthIndex : monthIndex;
|
|
407
|
-
if (idx === MonthIndex.
|
|
408
|
-
return MonthIndex.
|
|
426
|
+
if (idx === MonthIndex.Migasir)
|
|
427
|
+
return MonthIndex.Kadeuk; // មិគសិរ -> កត្ដិក
|
|
409
428
|
if (idx === MonthIndex.Srap && leapType === 1)
|
|
410
|
-
return MonthIndex.
|
|
411
|
-
if (idx === MonthIndex.
|
|
412
|
-
return MonthIndex.
|
|
413
|
-
if (idx === MonthIndex.
|
|
429
|
+
return MonthIndex.Tutiyasadh; // ស្រាពណ៍ -> ទុតិយាសាឍ (leap)
|
|
430
|
+
if (idx === MonthIndex.Tutiyasadh)
|
|
431
|
+
return MonthIndex.Pathamasadh; // ទុតិយាសាឍ -> បឋមាសាឍ
|
|
432
|
+
if (idx === MonthIndex.Pathamasadh)
|
|
414
433
|
return MonthIndex.Jesth; // បឋមាសាឍ -> ជេស្ឋ
|
|
415
434
|
return (idx - 1);
|
|
416
435
|
}
|
|
@@ -601,7 +620,7 @@ class KhmerDate {
|
|
|
601
620
|
const newDayNum = currentDayNum + remaining;
|
|
602
621
|
const newDay = KhmerDate.fromDayNumber(newDayNum);
|
|
603
622
|
let newBeYear = result.beYear;
|
|
604
|
-
if (result.monthIndex === MonthIndex.
|
|
623
|
+
if (result.monthIndex === MonthIndex.Pisakh) { // ពិសាខ
|
|
605
624
|
if (result.moonPhase === MoonPhase.Waxing && newDay.moonPhase === MoonPhase.Waning) {
|
|
606
625
|
newBeYear++;
|
|
607
626
|
}
|
|
@@ -612,7 +631,7 @@ class KhmerDate {
|
|
|
612
631
|
else {
|
|
613
632
|
remaining -= (daysLeftInMonth + 1);
|
|
614
633
|
const nextMonth = nextMonthOf(result.monthIndex, result.beYear);
|
|
615
|
-
const newBeYear = (result.monthIndex === MonthIndex.
|
|
634
|
+
const newBeYear = (result.monthIndex === MonthIndex.Cheit) ? result.beYear + 1 : result.beYear;
|
|
616
635
|
result = new KhmerDate(1, MoonPhase.Waxing, nextMonth, newBeYear); // Start at 1កើត
|
|
617
636
|
}
|
|
618
637
|
}
|
|
@@ -629,7 +648,7 @@ class KhmerDate {
|
|
|
629
648
|
const newDayNum = currentDayNum - remaining;
|
|
630
649
|
const newDay = KhmerDate.fromDayNumber(newDayNum);
|
|
631
650
|
let newBeYear = result.beYear;
|
|
632
|
-
if (result.monthIndex === MonthIndex.
|
|
651
|
+
if (result.monthIndex === MonthIndex.Pisakh) { // ពិសាខ
|
|
633
652
|
if (result.moonPhase === MoonPhase.Waning && newDay.moonPhase === MoonPhase.Waxing) {
|
|
634
653
|
newBeYear--;
|
|
635
654
|
}
|
|
@@ -640,7 +659,7 @@ class KhmerDate {
|
|
|
640
659
|
else {
|
|
641
660
|
remaining -= (currentDayNum + 1);
|
|
642
661
|
const prevMonth = previousMonthOf(result.monthIndex, result.beYear);
|
|
643
|
-
const newBeYear = (result.monthIndex === MonthIndex.
|
|
662
|
+
const newBeYear = (result.monthIndex === MonthIndex.Pisakh) ? result.beYear - 1 : result.beYear;
|
|
644
663
|
const daysInPrevMonth = getNumberOfDaysInKhmerMonth(prevMonth, newBeYear);
|
|
645
664
|
const newDay = KhmerDate.fromDayNumber(daysInPrevMonth - 1);
|
|
646
665
|
result = new KhmerDate(newDay.day, newDay.moonPhase, prevMonth, newBeYear);
|
|
@@ -649,7 +668,7 @@ class KhmerDate {
|
|
|
649
668
|
return result;
|
|
650
669
|
}
|
|
651
670
|
toString() {
|
|
652
|
-
return `${this.day}${
|
|
671
|
+
return `${this.day}${MoonPhaseNames[this.moonPhase]} ខែ${LunarMonthNames[this.monthIndex]} ព.ស.${this.beYear}`;
|
|
653
672
|
}
|
|
654
673
|
}
|
|
655
674
|
// ============================================================================
|
|
@@ -665,7 +684,7 @@ function getMaybeBEYear(year, month) {
|
|
|
665
684
|
return year + 544;
|
|
666
685
|
}
|
|
667
686
|
}
|
|
668
|
-
// Cache for
|
|
687
|
+
// Cache for Pisakha Bochea dates by year
|
|
669
688
|
const visakhaBocheaCache = {};
|
|
670
689
|
// Cache for New Year Full Info
|
|
671
690
|
const newYearInfoCache = {};
|
|
@@ -674,7 +693,7 @@ const newYearInfoCache = {};
|
|
|
674
693
|
* BE year increases on ១រោច ខែពិសាខ (1st waning day of Pisakh = dayNumber 15 of month 5)
|
|
675
694
|
* Returns timestamp in milliseconds at midnight of that day
|
|
676
695
|
*/
|
|
677
|
-
function
|
|
696
|
+
function getPisakhaBochea(year, isSearching = false) {
|
|
678
697
|
if (visakhaBocheaCache[year]) {
|
|
679
698
|
return visakhaBocheaCache[year];
|
|
680
699
|
}
|
|
@@ -684,7 +703,7 @@ function getVisakhaBochea(year, isSearching = false) {
|
|
|
684
703
|
for (let searchDay = 1; searchDay <= daysInMonth; searchDay++) {
|
|
685
704
|
// Avoid infinite recursion by using simplified BE year during search
|
|
686
705
|
const result = gregorianToKhmerInternal(year, searchMonth, searchDay, 12, 0, 0, true);
|
|
687
|
-
if (result.khmer.monthIndex === MonthIndex.
|
|
706
|
+
if (result.khmer.monthIndex === MonthIndex.Pisakh && result._khmerDateObj.getDayNumber() === 15) {
|
|
688
707
|
// Found 1រោច Pisakh - return timestamp at midnight (start of BE year change day)
|
|
689
708
|
// BE year changes at 00:00 on this day
|
|
690
709
|
const timestamp = new Date(year, searchMonth - 1, searchDay, 0, 0, 0, 0).getTime();
|
|
@@ -770,7 +789,7 @@ function gregorianToKhmerInternal(year, month, day, hour = 0, minute = 0, second
|
|
|
770
789
|
else {
|
|
771
790
|
// Normal mode: compare against exact BE year transition datetime (1រោច Pisakh at 00:00)
|
|
772
791
|
const inputTimestamp = new Date(year, month - 1, day, hour, minute, second).getTime();
|
|
773
|
-
const beYearTransitionTimestamp =
|
|
792
|
+
const beYearTransitionTimestamp = getPisakhaBochea(year);
|
|
774
793
|
if (inputTimestamp >= beYearTransitionTimestamp) {
|
|
775
794
|
// On or after 1រោច Pisakh (new BE year)
|
|
776
795
|
beYear = year + 544;
|
|
@@ -784,14 +803,14 @@ function gregorianToKhmerInternal(year, month, day, hour = 0, minute = 0, second
|
|
|
784
803
|
let jsYear = beToJs(beYear);
|
|
785
804
|
let animalYearIndex = ((beYear + 4) % 12 + 12) % 12;
|
|
786
805
|
// Adjust Era and Animal Year based on Khmer New Year logic
|
|
787
|
-
// They should change at New Year, not wait for
|
|
806
|
+
// They should change at New Year, not wait for Pisakha Bochea (which changes BE)
|
|
788
807
|
if (!isSearching) {
|
|
789
808
|
const newYearInfo = getNewYearFullInfo(year);
|
|
790
809
|
const inputTimestamp = new Date(year, month - 1, day, hour, minute, second).getTime();
|
|
791
|
-
const visakhaBocheaTimestamp =
|
|
810
|
+
const visakhaBocheaTimestamp = getPisakhaBochea(year);
|
|
792
811
|
// Animal Year changes at Moha Songkran (exact New Year time)
|
|
793
|
-
// Only apply manual increment if we are in the gap between New Year and
|
|
794
|
-
// (After
|
|
812
|
+
// Only apply manual increment if we are in the gap between New Year and Pisakha Bochea
|
|
813
|
+
// (After Pisakha Bochea, the BE year increments, so the formula based on BE automatically gives the new Animal Year)
|
|
795
814
|
if (inputTimestamp >= newYearInfo.newYearMoment.getTime() && inputTimestamp <= visakhaBocheaTimestamp) {
|
|
796
815
|
animalYearIndex = (animalYearIndex + 1) % 12;
|
|
797
816
|
}
|
|
@@ -800,7 +819,7 @@ function gregorianToKhmerInternal(year, month, day, hour = 0, minute = 0, second
|
|
|
800
819
|
jsYear++;
|
|
801
820
|
}
|
|
802
821
|
}
|
|
803
|
-
const
|
|
822
|
+
const sakIndex = ((jsYear % 10) + 10) % 10;
|
|
804
823
|
const dayOfWeek = getDayOfWeek(year, month, day);
|
|
805
824
|
const khmerDate = new KhmerDate(khmerDayInfo.day, khmerDayInfo.moonPhase, khmerMonth, beYear);
|
|
806
825
|
return {
|
|
@@ -808,15 +827,15 @@ function gregorianToKhmerInternal(year, month, day, hour = 0, minute = 0, second
|
|
|
808
827
|
khmer: {
|
|
809
828
|
day: khmerDayInfo.day,
|
|
810
829
|
moonPhase: khmerDayInfo.moonPhase,
|
|
811
|
-
moonPhaseName:
|
|
830
|
+
moonPhaseName: MoonPhaseNames[khmerDayInfo.moonPhase],
|
|
812
831
|
monthIndex: khmerMonth,
|
|
813
832
|
monthName: LunarMonthNames[khmerMonth],
|
|
814
833
|
beYear: beYear,
|
|
815
834
|
jsYear: jsYear,
|
|
816
835
|
animalYear: animalYearIndex,
|
|
817
836
|
animalYearName: AnimalYearNames[animalYearIndex],
|
|
818
|
-
|
|
819
|
-
|
|
837
|
+
sak: sakIndex,
|
|
838
|
+
sakName: SakNames[sakIndex],
|
|
820
839
|
dayOfWeek: dayOfWeek,
|
|
821
840
|
dayOfWeekName: WeekdayNames[dayOfWeek]
|
|
822
841
|
},
|
|
@@ -843,7 +862,7 @@ function khmerToGregorian(day, moonPhase, monthIndex, beYear) {
|
|
|
843
862
|
for (let gDay = 1; gDay <= daysInMonth; gDay++) {
|
|
844
863
|
// For BE year transition day (1រោច Pisakh) and the day before (15កើត Pisakh),
|
|
845
864
|
// check multiple times during the day because BE year can change during this period
|
|
846
|
-
const isAroundBEYearChange = monthIndexNum === MonthIndex.
|
|
865
|
+
const isAroundBEYearChange = monthIndexNum === MonthIndex.Pisakh &&
|
|
847
866
|
((day === 15 && moonPhaseNum === MoonPhase.Waxing) || (day === 1 && moonPhaseNum === MoonPhase.Waning));
|
|
848
867
|
const timesToCheck = isAroundBEYearChange
|
|
849
868
|
? [0, 6, 12, 18, 23] // Check at different hours
|
|
@@ -963,34 +982,47 @@ function getKhmerNewYear(ceYear) {
|
|
|
963
982
|
// ============================================================================
|
|
964
983
|
// Formatting Functions
|
|
965
984
|
// ============================================================================
|
|
966
|
-
function
|
|
985
|
+
function formatKhmer(khmerData, formatString) {
|
|
967
986
|
if (!formatString) {
|
|
968
987
|
// Default format
|
|
969
988
|
const { khmer } = khmerData;
|
|
970
989
|
const moonDay = `${khmer.day}${khmer.moonPhaseName}`;
|
|
971
|
-
return toKhmerNumeral(`ថ្ងៃ${khmer.dayOfWeekName} ${moonDay} ខែ${khmer.monthName} ឆ្នាំ${khmer.animalYearName} ${khmer.
|
|
990
|
+
return toKhmerNumeral(`ថ្ងៃ${khmer.dayOfWeekName} ${moonDay} ខែ${khmer.monthName} ឆ្នាំ${khmer.animalYearName} ${khmer.sakName} ពុទ្ធសករាជ ${khmer.beYear}`);
|
|
972
991
|
}
|
|
973
992
|
// Custom format
|
|
974
993
|
const formatRules = {
|
|
975
994
|
'W': () => khmerData.khmer.dayOfWeekName,
|
|
976
995
|
'w': () => WeekdayNamesShort[khmerData.gregorian.dayOfWeek],
|
|
977
|
-
'd': () => khmerData.khmer.day,
|
|
978
|
-
'D': () => (khmerData.khmer.day < 10 ? '0' : '') + khmerData.khmer.day,
|
|
979
|
-
'
|
|
996
|
+
'd': () => toKhmerNumeral(khmerData.khmer.day),
|
|
997
|
+
'D': () => toKhmerNumeral((khmerData.khmer.day < 10 ? '0' : '') + khmerData.khmer.day),
|
|
998
|
+
'dr': () => khmerData.khmer.day,
|
|
999
|
+
'Dr': () => (khmerData.khmer.day < 10 ? '0' : '') + khmerData.khmer.day,
|
|
1000
|
+
'n': () => MoonPhaseShort[khmerData.khmer.moonPhase],
|
|
980
1001
|
'N': () => khmerData.khmer.moonPhaseName,
|
|
981
1002
|
'o': () => MoonDaySymbols[khmerData._khmerDateObj.getDayNumber()],
|
|
982
1003
|
'm': () => khmerData.khmer.monthName,
|
|
983
1004
|
'M': () => SolarMonthNames[khmerData.gregorian.month - 1],
|
|
984
1005
|
'a': () => khmerData.khmer.animalYearName,
|
|
985
|
-
'
|
|
986
|
-
'
|
|
987
|
-
'
|
|
988
|
-
'
|
|
1006
|
+
'as': () => AnimalYearEmojis[khmerData.khmer.animalYear],
|
|
1007
|
+
'e': () => khmerData.khmer.sakName,
|
|
1008
|
+
'b': () => toKhmerNumeral(khmerData.khmer.beYear),
|
|
1009
|
+
'br': () => khmerData.khmer.beYear,
|
|
1010
|
+
'c': () => toKhmerNumeral(khmerData.gregorian.year),
|
|
1011
|
+
'cr': () => khmerData.gregorian.year,
|
|
1012
|
+
'j': () => toKhmerNumeral(khmerData.khmer.jsYear),
|
|
1013
|
+
'jr': () => khmerData.khmer.jsYear,
|
|
1014
|
+
'Ms': () => SolarMonthAbbreviationNames[khmerData.gregorian.month - 1],
|
|
1015
|
+
'ms': () => LunarMonthAbbreviationNames[khmerData.khmer.monthIndex]
|
|
989
1016
|
};
|
|
990
|
-
|
|
991
|
-
const
|
|
992
|
-
|
|
993
|
-
|
|
1017
|
+
// Sort keys by length descending to ensure longer tokens (like 'Ms', 'ms') are matched before shorter ones (like 'M', 'm')
|
|
1018
|
+
const sortedKeys = Object.keys(formatRules).sort((a, b) => b.length - a.length);
|
|
1019
|
+
const regex = new RegExp(`\\[([^\\]]+)\\]|(${sortedKeys.join('|')})`, 'g');
|
|
1020
|
+
const result = formatString.replace(regex, (match, escaped, token) => {
|
|
1021
|
+
if (escaped) {
|
|
1022
|
+
return escaped;
|
|
1023
|
+
}
|
|
1024
|
+
const value = formatRules[token]();
|
|
1025
|
+
return String(value);
|
|
994
1026
|
});
|
|
995
1027
|
return result;
|
|
996
1028
|
}
|
|
@@ -1004,49 +1036,57 @@ function gregorianToKhmer(year, month, day, hour = 0, minute = 0, second = 0) {
|
|
|
1004
1036
|
// ============================================================================
|
|
1005
1037
|
// Public API
|
|
1006
1038
|
// ============================================================================
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1039
|
+
// Conversion functions
|
|
1040
|
+
function fromGregorian(year, month, day, hour = 0, minute = 0, second = 0) {
|
|
1041
|
+
return gregorianToKhmer(year, month, day, hour, minute, second);
|
|
1042
|
+
}
|
|
1043
|
+
function fromKhmer(day, moonPhase, monthIndex, beYear) {
|
|
1044
|
+
return khmerToGregorian(day, moonPhase, monthIndex, beYear);
|
|
1045
|
+
}
|
|
1046
|
+
// New Year function
|
|
1047
|
+
function getNewYear(ceYear) {
|
|
1048
|
+
return getKhmerNewYear(ceYear);
|
|
1049
|
+
}
|
|
1050
|
+
// Format function
|
|
1051
|
+
function format(khmerData, formatString) {
|
|
1052
|
+
return formatKhmer(khmerData, formatString);
|
|
1053
|
+
}
|
|
1054
|
+
// Utility for creating date from Date object
|
|
1055
|
+
function fromDate(date) {
|
|
1056
|
+
// Validate Date object
|
|
1057
|
+
validateDateObject(date);
|
|
1058
|
+
return gregorianToKhmer(date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
|
|
1059
|
+
}
|
|
1060
|
+
// Convert Khmer to Date object
|
|
1061
|
+
function toDate(day, moonPhase, monthIndex, beYear) {
|
|
1062
|
+
const greg = khmerToGregorian(day, moonPhase, monthIndex, beYear);
|
|
1063
|
+
return new Date(greg.year, greg.month - 1, greg.day);
|
|
1064
|
+
}
|
|
1065
|
+
// Constants export
|
|
1066
|
+
exports.constants = {
|
|
1067
|
+
LunarMonths,
|
|
1068
|
+
LunarMonthNames,
|
|
1069
|
+
SolarMonthNames,
|
|
1070
|
+
SolarMonthAbbreviationNames,
|
|
1071
|
+
LunarMonthAbbreviationNames,
|
|
1072
|
+
AnimalYearNames,
|
|
1073
|
+
AnimalYearEmojis,
|
|
1074
|
+
SakNames,
|
|
1075
|
+
WeekdayNames,
|
|
1076
|
+
MoonPhaseNames
|
|
1077
|
+
};
|
|
1078
|
+
// Default export - aggregate all exports for convenience
|
|
1079
|
+
exports.default = {
|
|
1080
|
+
fromGregorian,
|
|
1081
|
+
fromKhmer,
|
|
1082
|
+
getNewYear,
|
|
1083
|
+
format,
|
|
1084
|
+
fromDate,
|
|
1085
|
+
toDate,
|
|
1086
|
+
constants: exports.constants,
|
|
1045
1087
|
MoonPhase,
|
|
1046
1088
|
MonthIndex,
|
|
1047
1089
|
AnimalYear,
|
|
1048
|
-
|
|
1090
|
+
Sak,
|
|
1049
1091
|
DayOfWeek
|
|
1050
1092
|
};
|
|
1051
|
-
// Default export
|
|
1052
|
-
exports.default = exports.momentkh;
|