@thyrith/momentkh 2.5.2 β 2.5.3
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 +1 -1
- package/index.html +169 -0
- package/momentkh.js +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[]()
|
|
6
6
|
|
|
7
7
|
# momentkh
|
|
8
|
-
momentkh is an add-on feature to moment js library
|
|
8
|
+
momentkh is an add-on feature to moment js library [DEMO](https://thyrithsor.github.io/momentkh).
|
|
9
9
|
|
|
10
10
|
## Install π
|
|
11
11
|
```
|
package/index.html
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
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/momentkh.js
CHANGED
|
@@ -314,10 +314,10 @@ khNewYearMoments = constant.khNewYearMoments
|
|
|
314
314
|
* @returns {*}
|
|
315
315
|
*/
|
|
316
316
|
function getBEYear(moment) {
|
|
317
|
-
if (moment.diff(getVisakhaBochea(moment.
|
|
318
|
-
return
|
|
317
|
+
if (moment.diff(getVisakhaBochea(moment.year())) > 0) {
|
|
318
|
+
return moment.year() + 544;
|
|
319
319
|
} else {
|
|
320
|
-
return
|
|
320
|
+
return moment.year() + 543;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
|
|
@@ -330,10 +330,10 @@ khNewYearMoments = constant.khNewYearMoments
|
|
|
330
330
|
* @returns {*}
|
|
331
331
|
*/
|
|
332
332
|
function getMaybeBEYear(moment) {
|
|
333
|
-
if (
|
|
334
|
-
return
|
|
333
|
+
if (moment.month() + 1 <= SolarMonth['ααααΆ'] + 1) {
|
|
334
|
+
return moment.year() + 543;
|
|
335
335
|
} else {
|
|
336
|
-
return
|
|
336
|
+
return moment.year() + 544;
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
|
|
@@ -352,7 +352,7 @@ khNewYearMoments = constant.khNewYearMoments
|
|
|
352
352
|
* @returns {number}
|
|
353
353
|
*/
|
|
354
354
|
function getJolakSakarajYear(moment) {
|
|
355
|
-
let gregorianYear =
|
|
355
|
+
let gregorianYear = moment.year();
|
|
356
356
|
let newYearMoment = getKhNewYearMoment(gregorianYear);
|
|
357
357
|
if (moment.diff(newYearMoment) < 0) {
|
|
358
358
|
return gregorianYear + 543 - 1182
|
|
@@ -379,7 +379,7 @@ khNewYearMoments = constant.khNewYearMoments
|
|
|
379
379
|
* @returns {number}
|
|
380
380
|
*/
|
|
381
381
|
function getAnimalYear(moment) {
|
|
382
|
-
let gregorianYear =
|
|
382
|
+
let gregorianYear = moment.year();
|
|
383
383
|
let newYearMoment = getKhNewYearMoment(gregorianYear);
|
|
384
384
|
if (moment.diff(newYearMoment) < 0) {
|
|
385
385
|
return (gregorianYear + 543 + 4) % 12
|
|
@@ -453,7 +453,7 @@ khNewYearMoments = constant.khNewYearMoments
|
|
|
453
453
|
return getBEYear(moment);
|
|
454
454
|
},
|
|
455
455
|
'c': function () {
|
|
456
|
-
return moment.
|
|
456
|
+
return moment.year();
|
|
457
457
|
},
|
|
458
458
|
'j': function () {
|
|
459
459
|
return getJolakSakarajYear(moment);
|