@thyrith/momentkh 2.5.5 → 3.0.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/README.md +1298 -93
- package/dist/momentkh.d.ts +196 -0
- package/dist/momentkh.d.ts.map +1 -0
- package/dist/momentkh.js +1063 -0
- package/momentkh.js +1053 -637
- package/momentkh.ts +1341 -0
- package/package.json +25 -2
- package/constant.js +0 -58
- package/example/newYearMoment.js +0 -4
- package/example/toKhDate.js +0 -6
- package/getSoriyatraLerngSak.js +0 -301
- package/index.html +0 -169
- package/locale/km.js +0 -70
package/package.json
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thyrith/momentkh",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Working on khmer calendar by implementting moment js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "component",
|
|
7
7
|
"repository": "ThyrithSor/momentkh",
|
|
8
8
|
"homepage": "https://github.com/ThyrithSor/momentkh",
|
|
9
9
|
"main": "momentkh.js",
|
|
10
|
+
"types": "dist/momentkh.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"momentkh.js",
|
|
13
|
+
"momentkh.ts",
|
|
14
|
+
"dist/",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc && node build-browser.js",
|
|
20
|
+
"build:dist": "tsc",
|
|
21
|
+
"test": "npm run test:validation && npm run test:gregorian && npm run test:khmer && npm run test:newyear && npm run test:verify-conversion && npm run test:verify-newyear && npm run test:verify-roundtrip",
|
|
22
|
+
"test:validation": "node test/validation.test.js",
|
|
23
|
+
"test:gregorian": "node test/gregorian-to-khmer.test.js",
|
|
24
|
+
"test:khmer": "node test/khmer-to-gregorian.test.js",
|
|
25
|
+
"test:newyear": "node test/new-year.test.js",
|
|
26
|
+
"test:verify-conversion": "node test/verify-conversion.test.js",
|
|
27
|
+
"test:verify-newyear": "node test/verify-new-year.test.js",
|
|
28
|
+
"test:verify-roundtrip": "node test/verify-roundtrip.test.js",
|
|
29
|
+
"prepublishOnly": "npm run build && npm test"
|
|
30
|
+
},
|
|
10
31
|
"authors": [
|
|
11
32
|
{
|
|
12
33
|
"name": "Thyrith Sor",
|
|
@@ -32,12 +53,14 @@
|
|
|
32
53
|
}
|
|
33
54
|
},
|
|
34
55
|
"dependencies": {
|
|
35
|
-
"moment": "^2.29.1"
|
|
36
56
|
},
|
|
37
57
|
"spm": {
|
|
38
58
|
"main": "momentkh.js",
|
|
39
59
|
"output": [
|
|
40
60
|
"locale/*.js"
|
|
41
61
|
]
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"typescript": "^5.9.3"
|
|
42
65
|
}
|
|
43
66
|
}
|
package/constant.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
;(function (global, factory) {
|
|
2
|
-
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
|
3
|
-
module.exports = factory()
|
|
4
|
-
} else {
|
|
5
|
-
if (typeof define === 'function' && define.amd) {
|
|
6
|
-
define(factory)
|
|
7
|
-
} else {
|
|
8
|
-
global.momentkhConstant = factory()
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}(this, (function () {
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
const LunarMonths = {};
|
|
15
|
-
"មិគសិរ_បុស្ស_មាឃ_ផល្គុន_ចេត្រ_ពិសាខ_ជេស្ឋ_អាសាឍ_ស្រាពណ៍_ភទ្របទ_អស្សុជ_កក្ដិក_បឋមាសាឍ_ទុតិយាសាឍ".split("_").forEach((month, index) => {
|
|
16
|
-
LunarMonths[month] = index
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const SolarMonth = {};
|
|
20
|
-
'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_').forEach((month, index) => {
|
|
21
|
-
SolarMonth[month] = index
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const AnimalYear = {};
|
|
25
|
-
"ជូត_ឆ្លូវ_ខាល_ថោះ_រោង_ម្សាញ់_មមីរ_មមែ_វក_រកា_ច_កុរ".split("_").forEach((year, index) => {
|
|
26
|
-
AnimalYear[year] = index
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const EraYear = {};
|
|
30
|
-
"សំរឹទ្ធិស័ក_ឯកស័ក_ទោស័ក_ត្រីស័ក_ចត្វាស័ក_បញ្ចស័ក_ឆស័ក_សប្តស័ក_អដ្ឋស័ក_នព្វស័ក".split("_").forEach((year, index) => {
|
|
31
|
-
EraYear[year] = index
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const MoonStatus = {};
|
|
35
|
-
"កើត_រោច".split("_").forEach((moon, index) => {
|
|
36
|
-
MoonStatus[moon] = index
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// ឆ្នាំលើកលែងមួយចំនួនដែលខុសពីការគណនា
|
|
40
|
-
const khNewYearMoments = {
|
|
41
|
-
'1879' : '12-04-1879 11:36',
|
|
42
|
-
'1897' : '13-04-1897 02:00',
|
|
43
|
-
'2011' : '14-04-2011 13:12',
|
|
44
|
-
'2012' : '14-04-2012 19:11',
|
|
45
|
-
'2013' : '14-04-2013 02:12',
|
|
46
|
-
'2014' : '14-04-2014 08:07',
|
|
47
|
-
'2015' : '14-04-2015 14:02',
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
LunarMonths,
|
|
52
|
-
SolarMonth,
|
|
53
|
-
AnimalYear,
|
|
54
|
-
EraYear,
|
|
55
|
-
MoonStatus,
|
|
56
|
-
khNewYearMoments,
|
|
57
|
-
}
|
|
58
|
-
})));
|
package/example/newYearMoment.js
DELETED
package/example/toKhDate.js
DELETED
package/getSoriyatraLerngSak.js
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @see http://www.dahlina.com/education/khmer_new_year_time.html?fbclid=IwAR0Eq6US-F0LfplMjKzmiRn7rvPgi31i74Wpv4mNhU034mzdyj-3hYrCA8w
|
|
3
|
-
* @param jsYear
|
|
4
|
-
* @returns {{harkun, kromathopol, avaman, bodithey, has366day: *, isAthikameas: *, isChantreathimeas: *, jesthHas30: *, dayLerngSak: number, lunarDateLerngSak: {day: number, month: *}}}
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
;(function (global, factory) {
|
|
8
|
-
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
|
9
|
-
module.exports = factory
|
|
10
|
-
} else {
|
|
11
|
-
if (typeof define === 'function' && define.amd) {
|
|
12
|
-
define(factory)
|
|
13
|
-
} else {
|
|
14
|
-
global.getSoriyatraLerngSak = factory
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}(this, (function (jsYear) {
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
return (function (jsYear) {
|
|
21
|
-
|
|
22
|
-
let LunarMonths;
|
|
23
|
-
|
|
24
|
-
if (typeof require === 'function') {
|
|
25
|
-
LunarMonths = require('./constant').LunarMonths;
|
|
26
|
-
} else {
|
|
27
|
-
if (!window.momentkhConstant) {
|
|
28
|
-
throw "Please import [MOMENTKH]/constant.js to your project"
|
|
29
|
-
} else {
|
|
30
|
-
LunarMonths = window.momentkhConstant.LunarMonths;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* គណនា ហារគុន Kromathopol អវមាន និង បូតិថី
|
|
36
|
-
* @param jsYear
|
|
37
|
-
* @returns {{bodithey: number, avaman: number, kromathopol: number, harkun: number}}
|
|
38
|
-
*/
|
|
39
|
-
function getInfo(jsYear) {
|
|
40
|
-
let h = 292207 * jsYear + 373;
|
|
41
|
-
let harkun = Math.floor(h / 800) + 1;
|
|
42
|
-
let kromathopol = 800 - (h % 800);
|
|
43
|
-
|
|
44
|
-
let a = 11 * harkun + 650;
|
|
45
|
-
let avaman = a % 692;
|
|
46
|
-
let bodithey = (harkun + Math.floor((a / 692))) % 30;
|
|
47
|
-
return {
|
|
48
|
-
harkun,
|
|
49
|
-
kromathopol,
|
|
50
|
-
avaman,
|
|
51
|
-
bodithey
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let info = getInfo(jsYear);
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* ឆ្នាំចុល្លសករាជដែលមាន៣៦៦ថ្ងៃ
|
|
59
|
-
* @param jsYear
|
|
60
|
-
* @returns {boolean}
|
|
61
|
-
*/
|
|
62
|
-
function getHas366day(jsYear) {
|
|
63
|
-
let infoOfYear = getInfo(jsYear);
|
|
64
|
-
return infoOfYear.kromathopol <= 207;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* រកឆ្នាំអធិកមាស
|
|
69
|
-
* @param jsYear
|
|
70
|
-
* @returns {boolean}
|
|
71
|
-
*/
|
|
72
|
-
function getIsAthikameas(jsYear) {
|
|
73
|
-
let infoOfYear = getInfo(jsYear);
|
|
74
|
-
let infoOfNextYear = getInfo(jsYear + 1);
|
|
75
|
-
return (!(infoOfYear.bodithey === 25 && infoOfNextYear.bodithey === 5) &&
|
|
76
|
-
(infoOfYear.bodithey > 24 ||
|
|
77
|
-
infoOfYear.bodithey < 6 ||
|
|
78
|
-
(infoOfYear.bodithey === 24 &&
|
|
79
|
-
infoOfNextYear.bodithey === 6
|
|
80
|
-
)
|
|
81
|
-
)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* រកឆ្នាំចន្ទ្រាធិមាស
|
|
87
|
-
* @param jsYear
|
|
88
|
-
* @returns {boolean}
|
|
89
|
-
*/
|
|
90
|
-
function getIsChantreathimeas(jsYear) {
|
|
91
|
-
let infoOfYear = getInfo(jsYear);
|
|
92
|
-
let infoOfNextYear = getInfo(jsYear + 1);
|
|
93
|
-
let infoOfPreviousYear = getInfo(jsYear - 1);
|
|
94
|
-
let has366day = getHas366day(jsYear);
|
|
95
|
-
return ((has366day && infoOfYear.avaman < 127) ||
|
|
96
|
-
(!(infoOfYear.avaman === 137 &&
|
|
97
|
-
infoOfNextYear.avaman === 0) &&
|
|
98
|
-
((!has366day &&
|
|
99
|
-
infoOfYear.avaman < 138) ||
|
|
100
|
-
(infoOfPreviousYear.avaman === 137 &&
|
|
101
|
-
infoOfYear.avaman === 0
|
|
102
|
-
)
|
|
103
|
-
)
|
|
104
|
-
)
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
let has366day = getHas366day(jsYear);
|
|
109
|
-
let isAthikameas = getIsAthikameas(jsYear)
|
|
110
|
-
let isChantreathimeas = getIsChantreathimeas(jsYear)
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* ឆែកមើលថាជាឆ្នាំដែលខែជេស្ឋមាន៣០ថ្ងៃឬទេ
|
|
114
|
-
* @type {boolean}
|
|
115
|
-
*/
|
|
116
|
-
let jesthHas30 = (function () {
|
|
117
|
-
let tmp = isChantreathimeas;
|
|
118
|
-
if (isAthikameas && isChantreathimeas) {
|
|
119
|
-
tmp = false;
|
|
120
|
-
}
|
|
121
|
-
if (!isChantreathimeas && getIsAthikameas(jsYear - 1) && getIsChantreathimeas(jsYear - 1)) {
|
|
122
|
-
tmp = true;
|
|
123
|
-
}
|
|
124
|
-
return tmp;
|
|
125
|
-
})();
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* រកមើលថាតើថ្ងៃឡើងស័កចំថ្ងៃអ្វី
|
|
129
|
-
* @type {number}
|
|
130
|
-
*/
|
|
131
|
-
let dayLerngSak = (info.harkun - 2) % 7;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* គណនារកថ្ងៃឡើងស័ក
|
|
135
|
-
* @type {{month, day}}
|
|
136
|
-
*/
|
|
137
|
-
let lunarDateLerngSak = (function () {
|
|
138
|
-
let bodithey = info.bodithey;
|
|
139
|
-
if (getIsAthikameas(jsYear - 1) && getIsChantreathimeas(jsYear - 1)) {
|
|
140
|
-
bodithey = (bodithey + 1) % 30;
|
|
141
|
-
}
|
|
142
|
-
return {
|
|
143
|
-
day: bodithey >= 6 ? bodithey - 1 : bodithey,
|
|
144
|
-
month: bodithey >= 6 ? LunarMonths['ចេត្រ'] : LunarMonths['ពិសាខ']
|
|
145
|
-
};
|
|
146
|
-
})();
|
|
147
|
-
|
|
148
|
-
function getSunInfo(sotin) { // សុទិន
|
|
149
|
-
let infoOfPreviousYear = getInfo(jsYear - 1);
|
|
150
|
-
// ១ រាសី = ៣០ អង្សា
|
|
151
|
-
// ១ អង្សា = ៦០ លិប្ដា
|
|
152
|
-
let sunAverageAsLibda = (function () { // មធ្យមព្រះអាទិត្យ គិតជាលិប្ដា
|
|
153
|
-
let r2 = 800 * sotin + infoOfPreviousYear.kromathopol;
|
|
154
|
-
let reasey = Math.floor(r2 / 24350); // រាសី
|
|
155
|
-
let r3 = r2 % 24350;
|
|
156
|
-
let angsar = Math.floor(r3 / 811); // អង្សា
|
|
157
|
-
let r4 = r3 % 811;
|
|
158
|
-
let l1 = Math.floor(r4 / 14);
|
|
159
|
-
let libda = l1 - 3; // លិប្ដា
|
|
160
|
-
return (30 * 60 * reasey) + (60 * angsar) + libda;
|
|
161
|
-
})();
|
|
162
|
-
|
|
163
|
-
let leftOver = (function () {
|
|
164
|
-
let s1 = ((30 * 60 * 2) + (60 * 20));
|
|
165
|
-
let leftOver = sunAverageAsLibda - s1; // មធ្យមព្រះអាទិត្យ - R2.A20.L0
|
|
166
|
-
if (sunAverageAsLibda < s1) { // បើតូចជាង ខ្ចី ១២ រាសី
|
|
167
|
-
leftOver += (30 * 60 * 12)
|
|
168
|
-
}
|
|
169
|
-
return leftOver;
|
|
170
|
-
})();
|
|
171
|
-
|
|
172
|
-
let kaen = (function () {
|
|
173
|
-
return Math.floor(leftOver / (30 * 60));
|
|
174
|
-
})();
|
|
175
|
-
|
|
176
|
-
let lastLeftOver = (function () {
|
|
177
|
-
let rs = -1;
|
|
178
|
-
if ([0, 1, 2].includes(kaen)) {
|
|
179
|
-
rs = kaen;
|
|
180
|
-
} else if ([3, 4, 5].includes(kaen)) {
|
|
181
|
-
rs = (30 * 60 * 6) - leftOver; // R6.A0.L0 - leftover
|
|
182
|
-
} else if ([6, 7, 8].includes(kaen)) {
|
|
183
|
-
rs = leftOver - (30 * 60 * 6); // leftover - R6.A0.L0
|
|
184
|
-
} else if ([9, 10, 11].includes(kaen)) {
|
|
185
|
-
rs = ((30 * 60 * 11) + (60 * 29) + 60) - leftOver; // R11.A29.L60 - leftover
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
reasey: Math.floor(rs / (30 * 60)),
|
|
189
|
-
angsar: Math.floor((rs % (30 * 60)) / (60)),
|
|
190
|
-
libda: rs % 60
|
|
191
|
-
};
|
|
192
|
-
})();
|
|
193
|
-
|
|
194
|
-
let [khan, pouichalip] = (function () { // ខណ្ឌ និង pouichalip
|
|
195
|
-
if (lastLeftOver.angsar >= 15) {
|
|
196
|
-
return [
|
|
197
|
-
2 * lastLeftOver.reasey + 1,
|
|
198
|
-
60 * (lastLeftOver.angsar - 15) + lastLeftOver.libda
|
|
199
|
-
];
|
|
200
|
-
} else {
|
|
201
|
-
return [
|
|
202
|
-
2 * lastLeftOver.reasey,
|
|
203
|
-
60 * lastLeftOver.angsar + lastLeftOver.libda
|
|
204
|
-
];
|
|
205
|
-
}
|
|
206
|
-
})();
|
|
207
|
-
|
|
208
|
-
let phol = (function () { // phol
|
|
209
|
-
const chhayaSun = function (khan) {
|
|
210
|
-
let multiplicities = [35, 32, 27, 22, 13, 5];
|
|
211
|
-
let chhayas = [0, 35, 67, 94, 116, 129];
|
|
212
|
-
switch (khan) {
|
|
213
|
-
case 0:
|
|
214
|
-
case 1:
|
|
215
|
-
case 2:
|
|
216
|
-
case 3:
|
|
217
|
-
case 4:
|
|
218
|
-
case 5:
|
|
219
|
-
return {
|
|
220
|
-
multiplicity: multiplicities[khan],
|
|
221
|
-
chhaya: chhayas[khan]
|
|
222
|
-
}
|
|
223
|
-
default:
|
|
224
|
-
return {
|
|
225
|
-
chhaya: 134
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
let val = chhayaSun(khan);
|
|
231
|
-
let q = Math.floor((pouichalip * val.multiplicity) / 900);
|
|
232
|
-
return {
|
|
233
|
-
reasey: 0,
|
|
234
|
-
angsar: Math.floor((q + val.chhaya) / 60),
|
|
235
|
-
libda: (q + val.chhaya) % 60
|
|
236
|
-
}
|
|
237
|
-
})();
|
|
238
|
-
|
|
239
|
-
let sunInaugurationAsLibda = (function () { // សម្ពោធព្រះអាទិត្យ
|
|
240
|
-
let pholAsLibda = (30 * 60 * phol.reasey) + (60 * phol.angsar) + phol.libda;
|
|
241
|
-
if (kaen <= 5) {
|
|
242
|
-
return sunAverageAsLibda - pholAsLibda;
|
|
243
|
-
} else {
|
|
244
|
-
return sunAverageAsLibda + pholAsLibda;
|
|
245
|
-
}
|
|
246
|
-
})();
|
|
247
|
-
|
|
248
|
-
return {
|
|
249
|
-
sunAverageAsLibda,
|
|
250
|
-
khan,
|
|
251
|
-
pouichalip,
|
|
252
|
-
phol,
|
|
253
|
-
sunInaugurationAsLibda
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
let newYearsDaySotins = (function () { // ចំនួនថ្ងៃវ័នបត
|
|
258
|
-
let sotins = getHas366day(jsYear - 1) ? [363, 364, 365, 366] : [362, 363, 364, 365]; // សុទិន
|
|
259
|
-
return sotins.map(function (sotin) {
|
|
260
|
-
let sunInfo = getSunInfo(sotin);
|
|
261
|
-
return {
|
|
262
|
-
sotin: sotin,
|
|
263
|
-
reasey: Math.floor(sunInfo.sunInaugurationAsLibda / (30 * 60)),
|
|
264
|
-
angsar: Math.floor((sunInfo.sunInaugurationAsLibda % (30 * 60)) / (60)), // អង្សាស្មើសូន្យ គីជាថ្ងៃចូលឆ្នាំ, មួយ ឬ ពីរ ថ្ងៃបន្ទាប់ជាថ្ងៃវ័នបត ហើយ ថ្ងៃចុងក្រោយគីឡើងស័ក
|
|
265
|
-
libda: sunInfo.sunInaugurationAsLibda % 60,
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
})();
|
|
269
|
-
|
|
270
|
-
let timeOfNewYear = (function () {
|
|
271
|
-
let sotinNewYear = newYearsDaySotins.filter(function (sotin) {
|
|
272
|
-
return sotin.angsar === 0;
|
|
273
|
-
});
|
|
274
|
-
if (sotinNewYear.length > 0) {
|
|
275
|
-
let libda = sotinNewYear[0].libda; // ២៤ ម៉ោង មាន ៦០លិប្ដា
|
|
276
|
-
let minutes = (24 * 60) - (libda * 24)
|
|
277
|
-
return {
|
|
278
|
-
hour: Math.floor(minutes / 60),
|
|
279
|
-
minute: minutes % 60
|
|
280
|
-
}
|
|
281
|
-
} else {
|
|
282
|
-
throw Error('Plugin is facing wrong calculation on new years hour. No sotin with angsar = 0');
|
|
283
|
-
}
|
|
284
|
-
})();
|
|
285
|
-
|
|
286
|
-
return {
|
|
287
|
-
harkun: info.harkun,
|
|
288
|
-
kromathopol: info.kromathopol,
|
|
289
|
-
avaman: info.avaman,
|
|
290
|
-
bodithey: info.bodithey,
|
|
291
|
-
has366day, // សុរិយគតិខ្មែរ
|
|
292
|
-
isAthikameas, // 13 months
|
|
293
|
-
isChantreathimeas, // 30ថ្ងៃនៅខែជេស្ឋ
|
|
294
|
-
jesthHas30, // ខែជេស្ឋមាន៣០ថ្ងៃ
|
|
295
|
-
dayLerngSak, // ថ្ងៃឡើងស័ក ច័ន្ទ អង្គារ ...
|
|
296
|
-
lunarDateLerngSak, // ថ្ងៃទី ខែ ឡើងស័ក
|
|
297
|
-
newYearsDaySotins, // សុទិនសម្រាប់គណនាថ្ងៃចូលឆ្នាំ ថ្ងៃវ័នបត និង ថ្ងៃឡើងស័ក
|
|
298
|
-
timeOfNewYear // ម៉ោងទេវតាចុះ
|
|
299
|
-
}
|
|
300
|
-
})(jsYear);
|
|
301
|
-
})));
|
package/index.html
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
<!-- To branch gh-pages -->
|
|
2
|
-
<!DOCTYPE html>
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<title>MomentKH</title>
|
|
6
|
-
<meta charset="utf-8">
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
8
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
|
-
<link href="https://fonts.googleapis.com/css2?family=Koh+Santepheap:wght@300&family=Moulpali&display=swap" rel="stylesheet">
|
|
11
|
-
<link rel="stylesheet" href="https://bootswatch.com/5/superhero/bootstrap.min.css">
|
|
12
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha512-SfTiTlX6kk+qitfevl/7LibUOeJWlt9rbyDn92a1DqWOw9vWG2MFoays0sgObmWazO5BQPiFucnnEAjpAB+/Sw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
|
13
|
-
|
|
14
|
-
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
|
15
|
-
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
|
16
|
-
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
|
17
|
-
|
|
18
|
-
<style>
|
|
19
|
-
body {
|
|
20
|
-
font-family: 'Koh Santepheap', cursive;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.pali {
|
|
24
|
-
font-family: 'Moulpali', cursive;
|
|
25
|
-
line-height: 2.5rem;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.vdp-datepicker__calendar {
|
|
29
|
-
background-color: #4e5d6c !important;
|
|
30
|
-
}
|
|
31
|
-
</style>
|
|
32
|
-
</head>
|
|
33
|
-
<body>
|
|
34
|
-
<div id="app">
|
|
35
|
-
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
|
36
|
-
<div class="container">
|
|
37
|
-
<a class="navbar-brand" href="#">momentkh</a>
|
|
38
|
-
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">
|
|
39
|
-
<span class="navbar-toggler-icon"></span>
|
|
40
|
-
</button>
|
|
41
|
-
|
|
42
|
-
<div class="collapse navbar-collapse" id="navbarColor02">
|
|
43
|
-
<ul class="navbar-nav me-auto">
|
|
44
|
-
<li class="nav-item">
|
|
45
|
-
<a class="nav-link active" href="#">Demo
|
|
46
|
-
<span class="visually-hidden">(current)</span>
|
|
47
|
-
</a>
|
|
48
|
-
</li>
|
|
49
|
-
<!-- <li class="nav-item">
|
|
50
|
-
<a class="nav-link" href="#">Support</a>
|
|
51
|
-
</li> -->
|
|
52
|
-
</ul>
|
|
53
|
-
<ul class="navbar-nav ms-md-auto">
|
|
54
|
-
<li class="nav-item">
|
|
55
|
-
<a target="_blank" rel="noopener" class="nav-link" href="https://github.com/ThyrithSor/momentkh"><i class="fa fa-github"></i> GitHub</a>
|
|
56
|
-
</li>
|
|
57
|
-
<li class="nav-item">
|
|
58
|
-
<a target="_blank" rel="noopener" class="nav-link" href="https://www.npmjs.com/package/@thyrith/momentkh">
|
|
59
|
-
<svg height="30px" aria-hidden="true" focusable="false" data-prefix="fab" data-icon="npm" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="svg-inline--fa fa-npm fa-w-18 fa-3x"><path fill="currentColor" d="M288 288h-32v-64h32v64zm288-128v192H288v32H160v-32H0V160h576zm-416 32H32v128h64v-96h32v96h32V192zm160 0H192v160h64v-32h64V192zm224 0H352v128h64v-96h32v96h32v-96h32v96h32V192z" class=""></path></svg>
|
|
60
|
-
NPM
|
|
61
|
-
</a>
|
|
62
|
-
</li>
|
|
63
|
-
</ul>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
</nav>
|
|
67
|
-
<div class="container">
|
|
68
|
-
<h1 class="mt-5 mb-2">
|
|
69
|
-
ប្រតិទិនខ្មែរ – momentkh
|
|
70
|
-
</h1>
|
|
71
|
-
<h2 class="my-4">
|
|
72
|
-
<svg style="margin-right: 10px;" height="30px" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="calendar-alt" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="svg-inline--fa fa-calendar-alt fa-w-14 fa-2x"><path fill="currentColor" d="M0 464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V192H0v272zm320-196c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM192 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM64 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zM400 64h-48V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H160V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H48C21.5 64 0 85.5 0 112v48h448v-48c0-26.5-21.5-48-48-48z" class=""></path></svg>
|
|
73
|
-
បម្លែងកាលបរិច្ឆេទពី moment instance ទៅកាលបរិច្ឆេទខ្មែរ</h2>
|
|
74
|
-
<div class="row my-5">
|
|
75
|
-
<p class="col-12 text-center">
|
|
76
|
-
{{ displayedDate }}
|
|
77
|
-
</p>
|
|
78
|
-
<div class="text-center py-4">
|
|
79
|
-
<svg style="transform: rotate(180deg); height: 40px;" aria-hidden="true" focusable="false" data-prefix="far" data-icon="hand-pointer" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="svg-inline--fa fa-hand-pointer fa-w-14 fa-3x"><path fill="currentColor" d="M358.182 179.361c-19.493-24.768-52.679-31.945-79.872-19.098-15.127-15.687-36.182-22.487-56.595-19.629V67c0-36.944-29.736-67-66.286-67S89.143 30.056 89.143 67v161.129c-19.909-7.41-43.272-5.094-62.083 8.872-29.355 21.795-35.793 63.333-14.55 93.152l109.699 154.001C134.632 501.59 154.741 512 176 512h178.286c30.802 0 57.574-21.5 64.557-51.797l27.429-118.999A67.873 67.873 0 0 0 448 326v-84c0-46.844-46.625-79.273-89.818-62.639zM80.985 279.697l27.126 38.079c8.995 12.626 29.031 6.287 29.031-9.283V67c0-25.12 36.571-25.16 36.571 0v175c0 8.836 7.163 16 16 16h6.857c8.837 0 16-7.164 16-16v-35c0-25.12 36.571-25.16 36.571 0v35c0 8.836 7.163 16 16 16H272c8.837 0 16-7.164 16-16v-21c0-25.12 36.571-25.16 36.571 0v21c0 8.836 7.163 16 16 16h6.857c8.837 0 16-7.164 16-16 0-25.121 36.571-25.16 36.571 0v84c0 1.488-.169 2.977-.502 4.423l-27.43 119.001c-1.978 8.582-9.29 14.576-17.782 14.576H176c-5.769 0-11.263-2.878-14.697-7.697l-109.712-154c-14.406-20.223 14.994-42.818 29.394-22.606zM176.143 400v-96c0-8.837 6.268-16 14-16h6c7.732 0 14 7.163 14 16v96c0 8.837-6.268 16-14 16h-6c-7.733 0-14-7.163-14-16zm75.428 0v-96c0-8.837 6.268-16 14-16h6c7.732 0 14 7.163 14 16v96c0 8.837-6.268 16-14 16h-6c-7.732 0-14-7.163-14-16zM327 400v-96c0-8.837 6.268-16 14-16h6c7.732 0 14 7.163 14 16v96c0 8.837-6.268 16-14 16h-6c-7.732 0-14-7.163-14-16z" class=""></path></svg>
|
|
80
|
-
</div>
|
|
81
|
-
<p class="pali col-12 text-center" v-html="displayedKhmerDate"></p>
|
|
82
|
-
</div>
|
|
83
|
-
<h2 class="my-4">
|
|
84
|
-
<svg style="margin-right: 10px;" height="30px" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="clock" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-clock fa-w-16 fa-3x"><path fill="currentColor" d="M256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8Zm92.49,313h0l-20,25a16,16,0,0,1-22.49,2.5h0l-67-49.72a40,40,0,0,1-15-31.23V112a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V256l58,42.5A16,16,0,0,1,348.49,321Z" class=""></path></svg>
|
|
85
|
-
ពេលដែលទេវតាចុះ ៖ គ.ស.
|
|
86
|
-
<vuejs-datepicker
|
|
87
|
-
:value="formattedDate"
|
|
88
|
-
:format="DatePickerFormat"
|
|
89
|
-
:language="language"
|
|
90
|
-
@selected="pickedYear"
|
|
91
|
-
minimum-view="year"
|
|
92
|
-
name="datepicker"
|
|
93
|
-
id="input-id"
|
|
94
|
-
wrapper-class="d-inline-block"
|
|
95
|
-
input-class="btn btn-secondary"></vuejs-datepicker>
|
|
96
|
-
</h2>
|
|
97
|
-
<div class="row my-5">
|
|
98
|
-
<p class="pali col-12 text-center">
|
|
99
|
-
{{ newYearMoment }}
|
|
100
|
-
</p>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
|
|
105
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
|
|
106
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/locale/km.min.js"></script>
|
|
107
|
-
<script src="https://unpkg.com/vuejs-datepicker"></script>
|
|
108
|
-
<script src="./constant.js"></script>
|
|
109
|
-
<script src="./locale/km.js"></script>
|
|
110
|
-
<script src="./getSoriyatraLerngSak.js"></script>
|
|
111
|
-
<script src="./momentkh.js"></script>
|
|
112
|
-
<script>
|
|
113
|
-
window.onload = function() {
|
|
114
|
-
var moment = momentkh(window.moment)
|
|
115
|
-
|
|
116
|
-
new Vue({
|
|
117
|
-
el: "#app",
|
|
118
|
-
data() {
|
|
119
|
-
return {
|
|
120
|
-
format: 'dN ខែm ឆ្នាំa e ព.ស. b',
|
|
121
|
-
now: moment(),
|
|
122
|
-
date: moment(),
|
|
123
|
-
DatePickerFormat: 'yyyy',
|
|
124
|
-
language: {
|
|
125
|
-
language: 'Khmer',
|
|
126
|
-
months: ['មករា', 'កុម្ភៈ', 'មីនា', 'មេសា', 'ឧសភា', 'មិថុនា', 'កក្កដា', 'សីហា', 'កញ្ញា', 'តុលា', 'វិច្ឆិកា', 'ធ្នូ'],
|
|
127
|
-
monthsAbbr: ['មករា', 'កុម្ភៈ', 'មីនា', 'មេសា', 'ឧសភា', 'មិថុនា', 'កក្កដា', 'សីហា', 'កញ្ញា', 'តុលា', 'វិច្ឆិកា', 'ធ្នូ'],
|
|
128
|
-
days: ['អាទិត្យ', 'ចន្ទ', 'អង្គារ', 'ពុធ', 'ព្រហស្បត្តិ៍', 'សុក្រ', 'សៅរ'],
|
|
129
|
-
rtl: false,
|
|
130
|
-
ymd: false,
|
|
131
|
-
yearSuffix: ''
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
computed: {
|
|
136
|
-
year() {
|
|
137
|
-
return this.date.year()
|
|
138
|
-
},
|
|
139
|
-
formattedDate() {
|
|
140
|
-
return this.date.locale('en').format('YYYY-MM-DD')
|
|
141
|
-
},
|
|
142
|
-
displayedDate() {
|
|
143
|
-
return this.now
|
|
144
|
-
},
|
|
145
|
-
displayedKhmerDate() {
|
|
146
|
-
return this.now.locale('km').format('ថ្ងៃdddd ទីDD ខែMMMM ឆ្នាំYYYY') + '<br/>ត្រូវនឹង<br/>ថ្ងៃទី ' + this.now.toKhDate(this.format) + '<br/>' + this.now.locale('km').format('h:mm:ss a')
|
|
147
|
-
},
|
|
148
|
-
newYearMoment() {
|
|
149
|
-
return moment.getKhNewYearMoment(this.year).locale('km').format('ថ្ងៃdddd ទីDD ខែMMMM ឆ្នាំYYYY វេលាម៉ោង h:mm នាទី a')
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
methods: {
|
|
153
|
-
pickedYear(year) {
|
|
154
|
-
this.date = moment(year)
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
mounted() {
|
|
158
|
-
setInterval(() => {
|
|
159
|
-
this.now = moment()
|
|
160
|
-
}, 1000)
|
|
161
|
-
},
|
|
162
|
-
components: {
|
|
163
|
-
'vuejs-datepicker':vuejsDatepicker
|
|
164
|
-
}
|
|
165
|
-
})
|
|
166
|
-
}
|
|
167
|
-
</script>
|
|
168
|
-
</body>
|
|
169
|
-
</html>
|
package/locale/km.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
//! moment.js locale configuration
|
|
2
|
-
|
|
3
|
-
;(function (global, factory) {
|
|
4
|
-
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
|
5
|
-
module.exports = factory()
|
|
6
|
-
} else {
|
|
7
|
-
if (typeof define === 'function' && define.amd) {
|
|
8
|
-
define(factory)
|
|
9
|
-
} else {
|
|
10
|
-
if (!global.momentkhLocales) {
|
|
11
|
-
global.momentkhLocales = {
|
|
12
|
-
'km': factory()
|
|
13
|
-
}
|
|
14
|
-
} else {
|
|
15
|
-
global.momentkhLocales['km'] = factory()
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}(this, (function () {
|
|
20
|
-
'use strict';
|
|
21
|
-
|
|
22
|
-
let symbolMap = {
|
|
23
|
-
'1': '១',
|
|
24
|
-
'2': '២',
|
|
25
|
-
'3': '៣',
|
|
26
|
-
'4': '៤',
|
|
27
|
-
'5': '៥',
|
|
28
|
-
'6': '៦',
|
|
29
|
-
'7': '៧',
|
|
30
|
-
'8': '៨',
|
|
31
|
-
'9': '៩',
|
|
32
|
-
'0': '០'
|
|
33
|
-
}, numberMap = {
|
|
34
|
-
'១': '1',
|
|
35
|
-
'២': '2',
|
|
36
|
-
'៣': '3',
|
|
37
|
-
'៤': '4',
|
|
38
|
-
'៥': '5',
|
|
39
|
-
'៦': '6',
|
|
40
|
-
'៧': '7',
|
|
41
|
-
'៨': '8',
|
|
42
|
-
'៩': '9',
|
|
43
|
-
'០': '0'
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
months: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
|
|
48
|
-
monthsShort: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
|
|
49
|
-
moonDays: '᧡_᧢_᧣_᧤_᧥_᧦_᧧_᧨_᧩_᧪_᧫_᧬_᧭_᧮_᧯_᧱_᧲_᧳_᧴_᧵_᧶_᧷_᧸_᧹_᧺_᧻_᧼_᧽_᧾_᧿'.split('_'),
|
|
50
|
-
moonStatus: "កើត_រោច".split("_"),
|
|
51
|
-
moonStatusShort: "ក_រ".split("_"),
|
|
52
|
-
weekdays: 'អាទិត្យ_ចន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
|
|
53
|
-
weekdaysShort: 'អា_ច_អ_ព_ព្រ_សុ_ស'.split('_'),
|
|
54
|
-
weekdaysMin: 'អា_ច_អ_ព_ព្រ_សុ_ស'.split('_'),
|
|
55
|
-
lunarMonths: "មិគសិរ_បុស្ស_មាឃ_ផល្គុន_ចេត្រ_ពិសាខ_ជេស្ឋ_អាសាឍ_ស្រាពណ៍_ភទ្របទ_អស្សុជ_កត្ដិក_បឋមាសាឍ_ទុតិយាសាឍ".split("_"),
|
|
56
|
-
animalYear: "ជូត_ឆ្លូវ_ខាល_ថោះ_រោង_ម្សាញ់_មមី_មមែ_វក_រកា_ច_កុរ".split("_"),
|
|
57
|
-
eraYear: "សំរឹទ្ធិស័ក_ឯកស័ក_ទោស័ក_ត្រីស័ក_ចត្វាស័ក_បញ្ចស័ក_ឆស័ក_សប្តស័ក_អដ្ឋស័ក_នព្វស័ក".split("_"),
|
|
58
|
-
preparse: function (string) {
|
|
59
|
-
return string.replace(/[១២៣៤៥៦៧៨៩០]/g, function (match) {
|
|
60
|
-
return numberMap[match];
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
postformat: function (string) {
|
|
64
|
-
return string.replace(/\d/g, function (match) {
|
|
65
|
-
return symbolMap[match];
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
})));
|