jsl-ui 9.28.2 → 9.28.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/lib/components/IntervalComponent.d.ts +17 -17
- package/lib/components/IntervalComponent.js +65 -68
- package/lib/components/auto-suggest/AutoSuggestComponent.d.ts +22 -22
- package/lib/components/auto-suggest/AutoSuggestComponent.js +47 -49
- package/lib/components/button/ButtonComponent.d.ts +18 -18
- package/lib/components/button/ButtonComponent.js +29 -46
- package/lib/components/checkbox/CheckBoxComponent.d.ts +28 -28
- package/lib/components/checkbox/CheckBoxComponent.js +81 -98
- package/lib/components/date/DateComponent.d.ts +32 -32
- package/lib/components/date/DateComponent.js +89 -106
- package/lib/components/date-range/DateRangeComponent.d.ts +35 -35
- package/lib/components/date-range/DateRangeComponent.js +123 -136
- package/lib/components/date-time/DateTimeComponent.d.ts +15 -15
- package/lib/components/date-time/DateTimeComponent.js +39 -53
- package/lib/components/dialog/DialogComponent.d.ts +67 -67
- package/lib/components/dialog/DialogComponent.js +198 -251
- package/lib/components/drop-down/DropDownComponent.d.ts +27 -27
- package/lib/components/drop-down/DropDownComponent.js +60 -74
- package/lib/components/expander/ExpanderComponent.d.ts +27 -27
- package/lib/components/expander/ExpanderComponent.js +89 -90
- package/lib/components/form-field/FormComponent.d.ts +12 -12
- package/lib/components/form-field/FormComponent.js +23 -26
- package/lib/components/form-field/FormFieldComponent.d.ts +39 -39
- package/lib/components/form-field/FormFieldComponent.js +138 -140
- package/lib/components/grid/GridComponent.d.ts +26 -26
- package/lib/components/grid/GridComponent.js +110 -116
- package/lib/components/input/InputComponent.d.ts +33 -33
- package/lib/components/input/InputComponent.js +126 -147
- package/lib/components/loading/LoadingComponent.d.ts +8 -8
- package/lib/components/loading/LoadingComponent.js +20 -22
- package/lib/components/navigation/NavigationComponent.d.ts +34 -34
- package/lib/components/navigation/NavigationComponent.js +45 -70
- package/lib/components/notification/Notification.d.ts +19 -19
- package/lib/components/notification/Notification.js +65 -69
- package/lib/components/number/NumberComponent.d.ts +26 -26
- package/lib/components/number/NumberComponent.js +80 -98
- package/lib/components/overlay/OverlayComponent.d.ts +27 -27
- package/lib/components/overlay/OverlayComponent.js +137 -149
- package/lib/components/progress/ProgressComponent.d.ts +18 -18
- package/lib/components/progress/ProgressComponent.js +40 -42
- package/lib/components/ribbon-menu/RibbonMenuComponent.d.ts +12 -12
- package/lib/components/ribbon-menu/RibbonMenuComponent.js +23 -34
- package/lib/components/select/SelectComponent.d.ts +79 -79
- package/lib/components/select/SelectComponent.js +356 -369
- package/lib/components/select/SelectDDAreaComponent.d.ts +32 -32
- package/lib/components/select/SelectDDAreaComponent.js +303 -317
- package/lib/components/slider/nouislider.d.ts +44 -44
- package/lib/components/slider/nouislider.js +2158 -2158
- package/lib/components/stack-panel/SplitterComponent.d.ts +21 -21
- package/lib/components/stack-panel/SplitterComponent.js +124 -126
- package/lib/components/stack-panel/StackPanelComponent.d.ts +20 -20
- package/lib/components/stack-panel/StackPanelComponent.js +50 -64
- package/lib/components/tabs/TabsComponent.d.ts +40 -40
- package/lib/components/tabs/TabsComponent.js +200 -204
- package/lib/components/time/TimeComponent.d.ts +29 -29
- package/lib/components/time/TimeComponent.js +104 -113
- package/lib/components/tree-view/TreeViewComponent.d.ts +23 -23
- package/lib/components/tree-view/TreeViewComponent.js +43 -45
- package/lib/components/virtual-render/VirtualRenderComponent.d.ts +30 -30
- package/lib/components/virtual-render/VirtualRenderComponent.js +92 -104
- package/lib/core/culture.d.ts +5 -5
- package/lib/core/culture.js +385 -385
- package/lib/core/date.d.ts +14 -14
- package/lib/core/date.js +346 -350
- package/lib/core/helper.d.ts +13 -13
- package/lib/core/helper.js +100 -104
- package/lib/core/jq.d.ts +37 -37
- package/lib/core/jq.js +362 -371
- package/lib/core/lang.d.ts +24 -24
- package/lib/core/lang.js +24 -28
- package/lib/core/numeric.d.ts +7 -7
- package/lib/core/numeric.js +139 -143
- package/lib/core/polyfills.js +22 -22
- package/lib/core.d.ts +6 -6
- package/lib/core.js +6 -6
- package/lib/grid/filterDialogs/dateRangeFilter.d.ts +7 -7
- package/lib/grid/filterDialogs/dateRangeFilter.js +106 -156
- package/lib/grid/filterDialogs/excelFilter.d.ts +9 -9
- package/lib/grid/filterDialogs/excelFilter.js +250 -316
- package/lib/grid/plugins/ext.overlay.d.ts +2 -2
- package/lib/grid/plugins/ext.overlay.js +295 -295
- package/lib/grid/plugins/slick.cellrangedecorator.d.ts +12 -12
- package/lib/grid/plugins/slick.cellrangedecorator.js +68 -68
- package/lib/grid/plugins/slick.cellrangeselector.d.ts +1 -1
- package/lib/grid/plugins/slick.cellrangeselector.js +144 -144
- package/lib/grid/plugins/slick.cellselectionmodel.d.ts +1 -1
- package/lib/grid/plugins/slick.cellselectionmodel.js +194 -194
- package/lib/grid/plugins/slick.headerbuttons.d.ts +55 -55
- package/lib/grid/plugins/slick.headerbuttons.js +156 -156
- package/lib/grid/plugins/slick.headermenu.d.ts +74 -74
- package/lib/grid/plugins/slick.headermenu.js +260 -260
- package/lib/grid/plugins/slick.rowmovemanager.d.ts +18 -18
- package/lib/grid/plugins/slick.rowmovemanager.js +249 -249
- package/lib/grid/plugins/slick.rowselectionmodel.d.ts +1 -1
- package/lib/grid/plugins/slick.rowselectionmodel.js +167 -167
- package/lib/grid/slick.core.d.ts +91 -91
- package/lib/grid/slick.core.js +574 -574
- package/lib/grid/slick.creator.d.ts +81 -81
- package/lib/grid/slick.creator.js +726 -726
- package/lib/grid/slick.dataview.d.ts +71 -71
- package/lib/grid/slick.dataview.js +1069 -1080
- package/lib/grid/slick.editors.core.d.ts +4 -4
- package/lib/grid/slick.editors.core.js +235 -235
- package/lib/grid/slick.editors.date.d.ts +2 -2
- package/lib/grid/slick.editors.date.js +125 -125
- package/lib/grid/slick.editors.lookup.d.ts +14 -14
- package/lib/grid/slick.editors.lookup.js +352 -353
- package/lib/grid/slick.editors.nav.d.ts +6 -6
- package/lib/grid/slick.editors.nav.js +22 -22
- package/lib/grid/slick.formatters.d.ts +17 -17
- package/lib/grid/slick.formatters.js +144 -144
- package/lib/grid/slick.grid.d.ts +285 -285
- package/lib/grid/slick.grid.js +5409 -5412
- package/lib/grid/slick.groupitemmetadataprovider.d.ts +39 -39
- package/lib/grid/slick.groupitemmetadataprovider.js +165 -165
- package/lib/grid/slick.tree.d.ts +33 -33
- package/lib/grid/slick.tree.js +208 -220
- package/lib/grid.css +1 -705
- package/lib/grid.d.ts +13 -13
- package/lib/grid.js +13 -13
- package/lib/index.css +8 -2195
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +56 -55
- package/lib/index.js +61 -61
- package/lib/index.js.map +1 -1
- package/lib/interaction/dataconverter.d.ts +4 -4
- package/lib/interaction/dataconverter.js +0 -1
- package/lib/interaction/eventhandler.d.ts +13 -13
- package/lib/interaction/eventhandler.js +39 -42
- package/lib/interaction/moveable.d.ts +39 -39
- package/lib/interaction/moveable.js +160 -174
- package/lib/interaction/resizable.d.ts +37 -37
- package/lib/interaction/resizable.js +109 -123
- package/lib/ui/auto.suggest.d.ts +18 -18
- package/lib/ui/auto.suggest.js +244 -259
- package/lib/ui/date.picker/date-picker-options.d.ts +11 -11
- package/lib/ui/date.picker/date-picker-options.js +76 -76
- package/lib/ui/date.picker/lib/date-manip.d.ts +74 -74
- package/lib/ui/date.picker/lib/date-manip.js +120 -120
- package/lib/ui/date.picker/lib/dom.d.ts +23 -23
- package/lib/ui/date.picker/lib/dom.js +28 -28
- package/lib/ui/date.picker/lib/emitter.d.ts +13 -13
- package/lib/ui/date.picker/lib/emitter.js +49 -49
- package/lib/ui/date.picker/lib/fns.d.ts +23 -23
- package/lib/ui/date.picker/lib/fns.js +39 -43
- package/lib/ui/date.picker/mode/base-mode.d.ts +26 -26
- package/lib/ui/date.picker/mode/base-mode.js +248 -248
- package/lib/ui/date.picker/mode/dropdown-mode.d.ts +28 -28
- package/lib/ui/date.picker/mode/dropdown-mode.js +50 -50
- package/lib/ui/date.picker/mode/index.d.ts +28 -28
- package/lib/ui/date.picker/mode/index.js +18 -18
- package/lib/ui/date.picker/mode/modal-mode.d.ts +25 -25
- package/lib/ui/date.picker/mode/modal-mode.js +17 -17
- package/lib/ui/date.picker/mode/permanent-mode.d.ts +29 -29
- package/lib/ui/date.picker/mode/permanent-mode.js +19 -19
- package/lib/ui/date.picker/views/day-picker.d.ts +40 -40
- package/lib/ui/date.picker/views/day-picker.js +155 -155
- package/lib/ui/date.picker/views/month-picker.d.ts +26 -26
- package/lib/ui/date.picker/views/month-picker.js +65 -65
- package/lib/ui/date.picker/views/year-picker.d.ts +20 -20
- package/lib/ui/date.picker/views/year-picker.js +66 -66
- package/lib/ui/date.picker.d.ts +66 -66
- package/lib/ui/date.picker.js +32 -32
- package/lib/ui/dialog.d.ts +22 -22
- package/lib/ui/dialog.js +98 -113
- package/lib/ui/drop.down.d.ts +52 -52
- package/lib/ui/drop.down.js +2112 -2112
- package/lib/ui/number.input.d.ts +13 -13
- package/lib/ui/number.input.js +56 -67
- package/package.json +1 -1
package/lib/core/date.js
CHANGED
|
@@ -1,350 +1,346 @@
|
|
|
1
|
-
import culture from "./culture";
|
|
2
|
-
/*
|
|
3
|
-
* contains function to parse and format numeric values
|
|
4
|
-
*/
|
|
5
|
-
//*** all following parts are extracted out of jquery-ui library (GPL/MIT license) ***/
|
|
6
|
-
var _helper = {
|
|
7
|
-
_defaults: { shortYearCutoff: "+10", dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] },
|
|
8
|
-
_ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) + Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
|
|
9
|
-
_daylightSavingAdjust
|
|
10
|
-
if (!date) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
|
|
14
|
-
return date;
|
|
15
|
-
},
|
|
16
|
-
_getDaysInMonth
|
|
17
|
-
return 32 - _helper._daylightSavingAdjust(new Date(year, month, 32)).getDate();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@param
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
@param
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
else {
|
|
348
|
-
return nr.toString();
|
|
349
|
-
}
|
|
350
|
-
}
|
|
1
|
+
import culture from "./culture";
|
|
2
|
+
/*
|
|
3
|
+
* contains function to parse and format numeric values
|
|
4
|
+
*/
|
|
5
|
+
//*** all following parts are extracted out of jquery-ui library (GPL/MIT license) ***/
|
|
6
|
+
var _helper = {
|
|
7
|
+
_defaults: { shortYearCutoff: "+10", dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] },
|
|
8
|
+
_ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) + Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
|
|
9
|
+
_daylightSavingAdjust(date) {
|
|
10
|
+
if (!date) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
|
|
14
|
+
return date;
|
|
15
|
+
},
|
|
16
|
+
_getDaysInMonth(year, month) {
|
|
17
|
+
return 32 - _helper._daylightSavingAdjust(new Date(year, month, 32)).getDate();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export class date {
|
|
21
|
+
/* Parse a string value into a date object.
|
|
22
|
+
See formatDate below for the possible formats.
|
|
23
|
+
|
|
24
|
+
@param format string - the expected format of the date
|
|
25
|
+
@param value string - the date in the above format
|
|
26
|
+
@param settings Object - attributes include:
|
|
27
|
+
shortYearCutoff number - the cutoff year for determining the century (optional)
|
|
28
|
+
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
|
|
29
|
+
dayNames string[7] - names of the days from Sunday (optional)
|
|
30
|
+
monthNamesShort string[12] - abbreviated names of the months (optional)
|
|
31
|
+
monthNames string[12] - names of the months (optional)
|
|
32
|
+
@return Date - the extracted date value or null if value is blank */
|
|
33
|
+
static parse(value, format, settings) {
|
|
34
|
+
if (value === null) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (value === undefined) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (value == "") {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
format = format || culture.info.dateFormat;
|
|
44
|
+
//value = (typeof value == 'object' ? value.toString() : value + '');
|
|
45
|
+
let shortYearCutoff = (settings ? settings.shortYearCutoff : null) || _helper._defaults.shortYearCutoff;
|
|
46
|
+
shortYearCutoff = (typeof shortYearCutoff != "string" ? shortYearCutoff :
|
|
47
|
+
new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
|
|
48
|
+
let dayNamesShort = (settings ? settings.dayNamesShort : null) || _helper._defaults.dayNamesShort;
|
|
49
|
+
let dayNames = (settings ? settings.dayNames : null) || _helper._defaults.dayNames;
|
|
50
|
+
let monthNamesShort = (settings ? settings.monthNamesShort : null) || _helper._defaults.monthNamesShort;
|
|
51
|
+
let monthNames = (settings ? settings.monthNames : null) || _helper._defaults.monthNames;
|
|
52
|
+
let year = -1;
|
|
53
|
+
let month = -1;
|
|
54
|
+
let day = -1;
|
|
55
|
+
let doy = -1;
|
|
56
|
+
let literal = false;
|
|
57
|
+
// Check whether a format character is doubled
|
|
58
|
+
let lookAhead = function (match) {
|
|
59
|
+
let matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
|
|
60
|
+
if (matches) {
|
|
61
|
+
iFormat++;
|
|
62
|
+
}
|
|
63
|
+
return matches;
|
|
64
|
+
};
|
|
65
|
+
// Extract a number from the string value
|
|
66
|
+
let getNumber = function (match) {
|
|
67
|
+
let isDoubled = lookAhead(match);
|
|
68
|
+
let size = (match == "@" ? 14 : (match == "!" ? 20 :
|
|
69
|
+
(match == "y" && isDoubled ? 4 : (match == "o" ? 3 : 2))));
|
|
70
|
+
let digits = new RegExp("^\\d{1," + size + "}");
|
|
71
|
+
let num = value.substring(iValue).match(digits);
|
|
72
|
+
if (!num) {
|
|
73
|
+
throw "Missing number at position " + iValue;
|
|
74
|
+
}
|
|
75
|
+
iValue += num[0].length;
|
|
76
|
+
return parseInt(num[0], 10);
|
|
77
|
+
};
|
|
78
|
+
// Extract a name from the string value and convert to an index
|
|
79
|
+
let getName = function (match, shortNames, longNames) {
|
|
80
|
+
let names = (lookAhead(match) ? longNames : shortNames);
|
|
81
|
+
for (let i = 0; i < names.length; i++) {
|
|
82
|
+
if (value.substr(iValue, names[i].length).toLowerCase() == names[i].toLowerCase()) {
|
|
83
|
+
iValue += names[i].length;
|
|
84
|
+
return i + 1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
throw new Error("Unknown name at position " + iValue);
|
|
88
|
+
};
|
|
89
|
+
// Confirm that a literal character matches the string value
|
|
90
|
+
let checkLiteral = function () {
|
|
91
|
+
if (value.charAt(iValue) != format.charAt(iFormat)) {
|
|
92
|
+
throw "Unexpected literal at position " + iValue;
|
|
93
|
+
}
|
|
94
|
+
iValue++;
|
|
95
|
+
};
|
|
96
|
+
let iValue = 0;
|
|
97
|
+
for (var iFormat = 0; iFormat < format.length; iFormat++) {
|
|
98
|
+
if (literal) {
|
|
99
|
+
if (format.charAt(iFormat) == "'" && !lookAhead("'")) {
|
|
100
|
+
literal = false;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
checkLiteral();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
switch (format.charAt(iFormat)) {
|
|
108
|
+
case "d":
|
|
109
|
+
day = getNumber("d");
|
|
110
|
+
break;
|
|
111
|
+
case "D":
|
|
112
|
+
getName("D", dayNamesShort, dayNames);
|
|
113
|
+
break;
|
|
114
|
+
case "o":
|
|
115
|
+
doy = getNumber("o");
|
|
116
|
+
break;
|
|
117
|
+
case "m":
|
|
118
|
+
month = getNumber("m");
|
|
119
|
+
break;
|
|
120
|
+
case "M":
|
|
121
|
+
month = getName("M", monthNamesShort, monthNames);
|
|
122
|
+
break;
|
|
123
|
+
case "y":
|
|
124
|
+
year = getNumber("y");
|
|
125
|
+
break;
|
|
126
|
+
case "@":
|
|
127
|
+
var date = new Date(getNumber("@"));
|
|
128
|
+
year = date.getFullYear();
|
|
129
|
+
month = date.getMonth() + 1;
|
|
130
|
+
day = date.getDate();
|
|
131
|
+
break;
|
|
132
|
+
case "!":
|
|
133
|
+
var date = new Date((getNumber("!") - _helper._ticksTo1970) / 10000);
|
|
134
|
+
year = date.getFullYear();
|
|
135
|
+
month = date.getMonth() + 1;
|
|
136
|
+
day = date.getDate();
|
|
137
|
+
break;
|
|
138
|
+
case "'":
|
|
139
|
+
if (lookAhead("'")) {
|
|
140
|
+
checkLiteral();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
literal = true;
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
default:
|
|
147
|
+
checkLiteral();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (year == -1) {
|
|
152
|
+
year = new Date().getFullYear();
|
|
153
|
+
}
|
|
154
|
+
else if (year < 100) {
|
|
155
|
+
year += new Date().getFullYear() - new Date().getFullYear() % 100 +
|
|
156
|
+
(year <= shortYearCutoff ? 0 : -100);
|
|
157
|
+
}
|
|
158
|
+
if (doy > -1) {
|
|
159
|
+
month = 1;
|
|
160
|
+
day = doy;
|
|
161
|
+
do {
|
|
162
|
+
let dim = _helper._getDaysInMonth(year, month - 1);
|
|
163
|
+
if (day <= dim) {
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
month++;
|
|
167
|
+
day -= dim;
|
|
168
|
+
} while (true);
|
|
169
|
+
}
|
|
170
|
+
let result = _helper._daylightSavingAdjust(new Date(year, month - 1, day));
|
|
171
|
+
if (result.getFullYear() != year || result.getMonth() + 1 != month || result.getDate() != day) {
|
|
172
|
+
throw new Error("Invalid date");
|
|
173
|
+
} // E.g. 31/02/*
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
/* Format a date object into a string value.
|
|
177
|
+
The format can be combinations of the following:
|
|
178
|
+
d - day of month (no leading zero)
|
|
179
|
+
dd - day of month (two digit)
|
|
180
|
+
o - day of year (no leading zeros)
|
|
181
|
+
oo - day of year (three digit)
|
|
182
|
+
D - day name short
|
|
183
|
+
DD - day name long
|
|
184
|
+
m - month of year (no leading zero)
|
|
185
|
+
mm - month of year (two digit)
|
|
186
|
+
M - month name short
|
|
187
|
+
MM - month name long
|
|
188
|
+
y - year (two digit)
|
|
189
|
+
yy - year (four digit)
|
|
190
|
+
@ - Unix timestamp (ms since 01/01/1970)
|
|
191
|
+
! - Windows ticks (100ns since 01/01/0001)
|
|
192
|
+
'...' - literal text
|
|
193
|
+
'' - single quote
|
|
194
|
+
|
|
195
|
+
@param format string - the desired format of the date
|
|
196
|
+
@param date Date - the date value to format
|
|
197
|
+
@param settings Object - attributes include:
|
|
198
|
+
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
|
|
199
|
+
dayNames string[7] - names of the days from Sunday (optional)
|
|
200
|
+
monthNamesShort string[12] - abbreviated names of the months (optional)
|
|
201
|
+
monthNames string[12] - names of the months (optional)
|
|
202
|
+
@return string - the date in the above format */
|
|
203
|
+
static format(date, format, settings) {
|
|
204
|
+
if (!date || isNaN(date)) {
|
|
205
|
+
return "";
|
|
206
|
+
}
|
|
207
|
+
format = format || culture.info.dateFormat;
|
|
208
|
+
let dayNamesShort = (settings ? settings.dayNamesShort : null) || _helper._defaults.dayNamesShort;
|
|
209
|
+
let dayNames = (settings ? settings.dayNames : null) || _helper._defaults.dayNames;
|
|
210
|
+
let monthNamesShort = (settings ? settings.monthNamesShort : null) || _helper._defaults.monthNamesShort;
|
|
211
|
+
let monthNames = (settings ? settings.monthNames : null) || _helper._defaults.monthNames;
|
|
212
|
+
// Check whether a format character is doubled
|
|
213
|
+
let lookAhead = function (match) {
|
|
214
|
+
let matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
|
|
215
|
+
if (matches) {
|
|
216
|
+
iFormat++;
|
|
217
|
+
}
|
|
218
|
+
return matches;
|
|
219
|
+
};
|
|
220
|
+
// Format a number, with leading zero if necessary
|
|
221
|
+
let formatNumber = function (match, value, len) {
|
|
222
|
+
let num = "" + value;
|
|
223
|
+
if (lookAhead(match)) {
|
|
224
|
+
while (num.length < len) {
|
|
225
|
+
num = "0" + num;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return num;
|
|
229
|
+
};
|
|
230
|
+
// Format a name, short or long as requested
|
|
231
|
+
let formatName = function (match, value, shortNames, longNames) {
|
|
232
|
+
return (lookAhead(match) ? longNames[value] : shortNames[value]);
|
|
233
|
+
};
|
|
234
|
+
let output = "";
|
|
235
|
+
let literal = false;
|
|
236
|
+
if (date) {
|
|
237
|
+
for (var iFormat = 0; iFormat < format.length; iFormat++) {
|
|
238
|
+
if (literal) {
|
|
239
|
+
if (format.charAt(iFormat) == "'" && !lookAhead("'")) {
|
|
240
|
+
literal = false;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
output += format.charAt(iFormat);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
switch (format.charAt(iFormat)) {
|
|
248
|
+
case "d":
|
|
249
|
+
output += formatNumber("d", date.getDate(), 2);
|
|
250
|
+
break;
|
|
251
|
+
case "D":
|
|
252
|
+
output += formatName("D", date.getDay(), dayNamesShort, dayNames);
|
|
253
|
+
break;
|
|
254
|
+
case "o":
|
|
255
|
+
output += formatNumber("o", (date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3);
|
|
256
|
+
break;
|
|
257
|
+
case "m":
|
|
258
|
+
output += formatNumber("m", date.getMonth() + 1, 2);
|
|
259
|
+
break;
|
|
260
|
+
case "M":
|
|
261
|
+
output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
|
|
262
|
+
break;
|
|
263
|
+
case "y":
|
|
264
|
+
output += (lookAhead("y") ? date.getFullYear() :
|
|
265
|
+
(date.getFullYear() % 100 < 10 ? "0" : "") + date.getFullYear() % 100);
|
|
266
|
+
break;
|
|
267
|
+
case "@":
|
|
268
|
+
output += date.getTime();
|
|
269
|
+
break;
|
|
270
|
+
case "!":
|
|
271
|
+
output += date.getTime() * 10000 + _helper._ticksTo1970;
|
|
272
|
+
break;
|
|
273
|
+
case "'":
|
|
274
|
+
if (lookAhead("'")) {
|
|
275
|
+
output += "'";
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
literal = true;
|
|
279
|
+
}
|
|
280
|
+
break;
|
|
281
|
+
default:
|
|
282
|
+
output += format.charAt(iFormat);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return output;
|
|
288
|
+
}
|
|
289
|
+
static formatTime(value, inputMode) {
|
|
290
|
+
if (inputMode === "HourMinute") {
|
|
291
|
+
return value ? (pad(value.getHours()) + ":" + pad(value.getMinutes())) : "";
|
|
292
|
+
}
|
|
293
|
+
else if (inputMode === "HourMinuteSecond") {
|
|
294
|
+
return value ? (pad(value.getHours()) + ":" + pad(value.getMinutes()) + ":" + pad(value.getSeconds())) : "";
|
|
295
|
+
}
|
|
296
|
+
return "";
|
|
297
|
+
}
|
|
298
|
+
static now() {
|
|
299
|
+
return new Date();
|
|
300
|
+
}
|
|
301
|
+
static addSeconds(d, seconds) {
|
|
302
|
+
const future = new Date(d);
|
|
303
|
+
future.setSeconds(d.getSeconds() + seconds);
|
|
304
|
+
return future;
|
|
305
|
+
}
|
|
306
|
+
static addMinutes(d, minutes) {
|
|
307
|
+
const future = new Date(d);
|
|
308
|
+
future.setMinutes(d.getMinutes() + minutes);
|
|
309
|
+
return future;
|
|
310
|
+
}
|
|
311
|
+
static addHours(d, hours) {
|
|
312
|
+
const future = new Date(d);
|
|
313
|
+
future.setHours(d.getHours() + hours);
|
|
314
|
+
return future;
|
|
315
|
+
}
|
|
316
|
+
static addDays(d, days) {
|
|
317
|
+
const future = new Date(d);
|
|
318
|
+
future.setDate(d.getDate() + days);
|
|
319
|
+
return future;
|
|
320
|
+
}
|
|
321
|
+
static getDaysBetween(startDate, endDate) {
|
|
322
|
+
return Math.round((endDate - startDate) / (1000.0 * 3600.0 * 24.0));
|
|
323
|
+
}
|
|
324
|
+
static getMsBetween(startDate, endDate) {
|
|
325
|
+
return endDate.getTime() - startDate.getTime();
|
|
326
|
+
}
|
|
327
|
+
static onlyDate(d) {
|
|
328
|
+
if (d == null) {
|
|
329
|
+
return d;
|
|
330
|
+
}
|
|
331
|
+
const result = new Date(d);
|
|
332
|
+
result.setHours(0, 0, 0, 0);
|
|
333
|
+
return result;
|
|
334
|
+
}
|
|
335
|
+
static equal(date1, date2) {
|
|
336
|
+
return (date1 && date1.getTime()) === (date2 && date2.getTime());
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function pad(nr) {
|
|
340
|
+
if (nr < 10) {
|
|
341
|
+
return "0" + nr.toString();
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
return nr.toString();
|
|
345
|
+
}
|
|
346
|
+
}
|