flatpickr-ce 4.8.0 → 4.9.0
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 +27 -0
- package/dist/esm/index.js +65 -44
- package/dist/esm/l10n/br.js +1 -1
- package/dist/esm/l10n/he.js +1 -1
- package/dist/esm/plugins/rangePlugin.js +34 -14
- package/dist/esm/plugins/yearSelect/index.js +341 -0
- package/dist/esm/utils/dates.js +2 -2
- package/dist/esm/utils/formatting.js +43 -35
- package/dist/flatpickr.js +141 -83
- package/dist/flatpickr.min.js +2 -2
- package/dist/l10n/br.js +1 -1
- package/dist/l10n/he.js +1 -1
- package/dist/l10n/index.js +2 -2
- package/dist/plugins/rangePlugin.js +50 -18
- package/dist/plugins/yearSelect/index.d.ts +14 -0
- package/dist/plugins/yearSelect/index.js +412 -0
- package/dist/plugins/yearSelect/style.css +108 -0
- package/dist/types/instance.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { clearNode, getEventTarget, toggleClass } from "../../utils/dom";
|
|
13
|
+
var defaultConfig = {
|
|
14
|
+
yearsPerPage: 12,
|
|
15
|
+
columns: 3,
|
|
16
|
+
dateFormat: "Y",
|
|
17
|
+
altFormat: "Y",
|
|
18
|
+
theme: "light",
|
|
19
|
+
};
|
|
20
|
+
function firstDayOfYear(year) {
|
|
21
|
+
var date = new Date(2000, 0, 1);
|
|
22
|
+
date.setFullYear(year, 0, 1);
|
|
23
|
+
return date;
|
|
24
|
+
}
|
|
25
|
+
function nextDay(date) {
|
|
26
|
+
var next = new Date(date.getTime());
|
|
27
|
+
next.setHours(0, 0, 0, 0);
|
|
28
|
+
next.setDate(next.getDate() + 1);
|
|
29
|
+
return next;
|
|
30
|
+
}
|
|
31
|
+
var mod = function (n, m) { return ((n % m) + m) % m; };
|
|
32
|
+
function yearSelectPlugin(pluginConfig) {
|
|
33
|
+
var config = __assign(__assign({}, defaultConfig), pluginConfig);
|
|
34
|
+
config.yearsPerPage = Math.max(1, Math.floor(config.yearsPerPage) || defaultConfig.yearsPerPage);
|
|
35
|
+
config.columns = Math.max(1, Math.floor(config.columns) || defaultConfig.columns);
|
|
36
|
+
return function (fp) {
|
|
37
|
+
fp.config.dateFormat = config.dateFormat;
|
|
38
|
+
fp.config.altFormat = config.altFormat;
|
|
39
|
+
var self = {
|
|
40
|
+
yearsContainer: null,
|
|
41
|
+
title: null,
|
|
42
|
+
};
|
|
43
|
+
var minYear = function () {
|
|
44
|
+
return fp.config.minDate ? fp.config.minDate.getFullYear() : null;
|
|
45
|
+
};
|
|
46
|
+
var maxYear = function () {
|
|
47
|
+
return fp.config.maxDate ? fp.config.maxDate.getFullYear() : null;
|
|
48
|
+
};
|
|
49
|
+
function clampYear(year) {
|
|
50
|
+
var min = minYear();
|
|
51
|
+
var max = maxYear();
|
|
52
|
+
if (max !== null && year > max)
|
|
53
|
+
year = max;
|
|
54
|
+
if (min !== null && year < min)
|
|
55
|
+
year = min;
|
|
56
|
+
return year;
|
|
57
|
+
}
|
|
58
|
+
var pageStartOf = function (year) { return year - mod(year, config.yearsPerPage); };
|
|
59
|
+
var pageStart = function () { return pageStartOf(fp.currentYear); };
|
|
60
|
+
function isPageInBounds(start) {
|
|
61
|
+
var min = minYear();
|
|
62
|
+
var max = maxYear();
|
|
63
|
+
return ((min === null || start + config.yearsPerPage - 1 >= min) &&
|
|
64
|
+
(max === null || start <= max));
|
|
65
|
+
}
|
|
66
|
+
function dateForYear(year) {
|
|
67
|
+
var min = minYear();
|
|
68
|
+
var max = maxYear();
|
|
69
|
+
if ((min !== null && year < min) || (max !== null && year > max))
|
|
70
|
+
return undefined;
|
|
71
|
+
var date = firstDayOfYear(year);
|
|
72
|
+
if (fp.config.minDate && date < fp.config.minDate)
|
|
73
|
+
date = new Date(fp.config.minDate.getTime());
|
|
74
|
+
for (; date.getFullYear() === year; date = nextDay(date)) {
|
|
75
|
+
if (fp.isEnabled(date, false))
|
|
76
|
+
return date;
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
function cellOf(year) {
|
|
81
|
+
var index = year - pageStart();
|
|
82
|
+
if (!self.yearsContainer || index < 0 || index >= config.yearsPerPage)
|
|
83
|
+
return null;
|
|
84
|
+
return self.yearsContainer.children[index];
|
|
85
|
+
}
|
|
86
|
+
function clearUnnecessaryDOMElements() {
|
|
87
|
+
if (!fp.rContainer)
|
|
88
|
+
return;
|
|
89
|
+
clearNode(fp.rContainer);
|
|
90
|
+
for (var _i = 0, _a = fp.monthElements; _i < _a.length; _i++) {
|
|
91
|
+
var element = _a[_i];
|
|
92
|
+
if (element.parentNode)
|
|
93
|
+
element.parentNode.removeChild(element);
|
|
94
|
+
}
|
|
95
|
+
for (var _b = 0, _c = fp.yearElements; _b < _c.length; _b++) {
|
|
96
|
+
var element = _c[_b];
|
|
97
|
+
var wrapper = element.parentNode;
|
|
98
|
+
if (wrapper && wrapper.parentNode)
|
|
99
|
+
wrapper.parentNode.removeChild(wrapper);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function build() {
|
|
103
|
+
if (!fp.rContainer)
|
|
104
|
+
return;
|
|
105
|
+
self.title = fp._createElement("span", "flatpickr-yearSelect-title");
|
|
106
|
+
self.title.setAttribute("aria-live", "polite");
|
|
107
|
+
var currentMonth = fp.monthNav.querySelector(".flatpickr-current-month");
|
|
108
|
+
if (currentMonth)
|
|
109
|
+
currentMonth.appendChild(self.title);
|
|
110
|
+
self.yearsContainer = fp._createElement("div", "flatpickr-yearSelect-years");
|
|
111
|
+
self.yearsContainer.tabIndex = -1;
|
|
112
|
+
self.yearsContainer.setAttribute("role", "listbox");
|
|
113
|
+
if (fp.config.mode !== "single")
|
|
114
|
+
self.yearsContainer.setAttribute("aria-multiselectable", "true");
|
|
115
|
+
fp.rContainer.appendChild(self.yearsContainer);
|
|
116
|
+
fp.calendarContainer.classList.add("flatpickr-yearSelect");
|
|
117
|
+
fp.calendarContainer.classList.add("flatpickr-yearSelect-theme-" + config.theme);
|
|
118
|
+
}
|
|
119
|
+
function buildYears() {
|
|
120
|
+
if (!self.yearsContainer)
|
|
121
|
+
return;
|
|
122
|
+
var focusedYear = self.yearsContainer.contains(document.activeElement)
|
|
123
|
+
? document.activeElement.$year
|
|
124
|
+
: undefined;
|
|
125
|
+
var selectedYears = fp.selectedDates.map(function (d) { return d.getFullYear(); });
|
|
126
|
+
var isRange = fp.config.mode === "range";
|
|
127
|
+
var rangeStart = isRange && selectedYears.length ? Math.min.apply(Math, selectedYears) : null;
|
|
128
|
+
var rangeEnd = isRange && selectedYears.length === 2
|
|
129
|
+
? Math.max.apply(Math, selectedYears) : null;
|
|
130
|
+
var thisYear = new Date().getFullYear();
|
|
131
|
+
var startYear = pageStart();
|
|
132
|
+
var lastYear = startYear + config.yearsPerPage - 1;
|
|
133
|
+
var width = 100 / config.columns + "%";
|
|
134
|
+
clearNode(self.yearsContainer);
|
|
135
|
+
var frag = document.createDocumentFragment();
|
|
136
|
+
for (var i = 0; i < config.yearsPerPage; i++) {
|
|
137
|
+
var year = startYear + i;
|
|
138
|
+
var date = dateForYear(year);
|
|
139
|
+
var selected = selectedYears.indexOf(year) !== -1;
|
|
140
|
+
var cell = fp._createElement("span", "flatpickr-yearSelect-year", String(year));
|
|
141
|
+
cell.tabIndex = -1;
|
|
142
|
+
cell.style.width = width;
|
|
143
|
+
cell.$year = year;
|
|
144
|
+
cell.dateObj = date || firstDayOfYear(year);
|
|
145
|
+
cell.setAttribute("role", "option");
|
|
146
|
+
cell.setAttribute("aria-label", String(year));
|
|
147
|
+
cell.setAttribute("aria-selected", String(selected));
|
|
148
|
+
if (year === thisYear) {
|
|
149
|
+
cell.classList.add("today");
|
|
150
|
+
cell.setAttribute("aria-current", "date");
|
|
151
|
+
}
|
|
152
|
+
if (selected)
|
|
153
|
+
cell.classList.add("selected");
|
|
154
|
+
if (rangeStart !== null) {
|
|
155
|
+
if (year === rangeStart)
|
|
156
|
+
cell.classList.add("startRange");
|
|
157
|
+
if (rangeEnd !== null) {
|
|
158
|
+
if (year === rangeEnd)
|
|
159
|
+
cell.classList.add("endRange");
|
|
160
|
+
if (year > rangeStart && year < rangeEnd)
|
|
161
|
+
cell.classList.add("inRange");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (date) {
|
|
165
|
+
cell.addEventListener("click", selectYear);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
cell.classList.add("flatpickr-disabled");
|
|
169
|
+
cell.setAttribute("aria-disabled", "true");
|
|
170
|
+
}
|
|
171
|
+
frag.appendChild(cell);
|
|
172
|
+
}
|
|
173
|
+
self.yearsContainer.appendChild(frag);
|
|
174
|
+
var pageLabel = startYear + " \u2013 " + lastYear;
|
|
175
|
+
if (self.title)
|
|
176
|
+
self.title.textContent = pageLabel;
|
|
177
|
+
self.yearsContainer.setAttribute("aria-label", pageLabel);
|
|
178
|
+
toggleClass(fp.prevMonthNav, "flatpickr-disabled", !isPageInBounds(startYear - config.yearsPerPage));
|
|
179
|
+
toggleClass(fp.nextMonthNav, "flatpickr-disabled", !isPageInBounds(startYear + config.yearsPerPage));
|
|
180
|
+
fp.prevMonthNav.setAttribute("aria-label", startYear - config.yearsPerPage + " \u2013 " + (startYear - 1));
|
|
181
|
+
fp.nextMonthNav.setAttribute("aria-label", lastYear + 1 + " \u2013 " + (lastYear + config.yearsPerPage));
|
|
182
|
+
if (focusedYear !== undefined) {
|
|
183
|
+
var cell = cellOf(focusedYear);
|
|
184
|
+
if (cell)
|
|
185
|
+
cell.focus();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function changePage(delta) {
|
|
189
|
+
var year = fp.currentYear + delta * config.yearsPerPage;
|
|
190
|
+
if (!isPageInBounds(pageStartOf(year)))
|
|
191
|
+
return;
|
|
192
|
+
fp.changeYear(clampYear(year));
|
|
193
|
+
}
|
|
194
|
+
function bindEvents() {
|
|
195
|
+
fp._bind(fp.prevMonthNav, "click", function (e) {
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
e.stopPropagation();
|
|
198
|
+
changePage(-1);
|
|
199
|
+
});
|
|
200
|
+
fp._bind(fp.nextMonthNav, "click", function (e) {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
e.stopPropagation();
|
|
203
|
+
changePage(1);
|
|
204
|
+
});
|
|
205
|
+
fp._bind(self.yearsContainer, "mouseover", function (e) {
|
|
206
|
+
if (fp.config.mode === "range")
|
|
207
|
+
fp.onMouseOver(getEventTarget(e), "flatpickr-yearSelect-year");
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
var isPickable = function (cell) {
|
|
211
|
+
return !cell.classList.contains("flatpickr-disabled") &&
|
|
212
|
+
!cell.classList.contains("notAllowed");
|
|
213
|
+
};
|
|
214
|
+
function selectYear(e) {
|
|
215
|
+
e.preventDefault();
|
|
216
|
+
e.stopPropagation();
|
|
217
|
+
var eventTarget = getEventTarget(e);
|
|
218
|
+
if (!(eventTarget instanceof Element) || !isPickable(eventTarget))
|
|
219
|
+
return;
|
|
220
|
+
setYear(eventTarget.$year);
|
|
221
|
+
}
|
|
222
|
+
function setYear(year) {
|
|
223
|
+
var date = dateForYear(year);
|
|
224
|
+
if (!date)
|
|
225
|
+
return;
|
|
226
|
+
var selectedDates = [];
|
|
227
|
+
switch (fp.config.mode) {
|
|
228
|
+
case "single":
|
|
229
|
+
selectedDates = [date];
|
|
230
|
+
break;
|
|
231
|
+
case "multiple":
|
|
232
|
+
selectedDates = fp.selectedDates.filter(function (d) { return d.getFullYear() !== year; });
|
|
233
|
+
if (selectedDates.length === fp.selectedDates.length)
|
|
234
|
+
selectedDates.push(date);
|
|
235
|
+
break;
|
|
236
|
+
case "range":
|
|
237
|
+
selectedDates =
|
|
238
|
+
fp.selectedDates.length === 2
|
|
239
|
+
? [date]
|
|
240
|
+
: fp.selectedDates.concat([date]);
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
fp.setDate(selectedDates, true);
|
|
244
|
+
fp.jumpToDate(date, true);
|
|
245
|
+
if (fp.config.closeOnSelect) {
|
|
246
|
+
var single = fp.config.mode === "single";
|
|
247
|
+
var range = fp.config.mode === "range" && fp.selectedDates.length === 2;
|
|
248
|
+
if (single || range)
|
|
249
|
+
fp.close();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function onKeyDown(_, __, ___, e) {
|
|
253
|
+
if (!self.yearsContainer)
|
|
254
|
+
return;
|
|
255
|
+
var shifts = {
|
|
256
|
+
37: -1,
|
|
257
|
+
39: 1,
|
|
258
|
+
38: -config.columns,
|
|
259
|
+
40: config.columns,
|
|
260
|
+
};
|
|
261
|
+
var shift = shifts[e.keyCode];
|
|
262
|
+
if (shift === undefined && e.keyCode !== 13)
|
|
263
|
+
return;
|
|
264
|
+
var active = document.activeElement;
|
|
265
|
+
var isYearFocused = !!active &&
|
|
266
|
+
self.yearsContainer.contains(active) &&
|
|
267
|
+
active.$year !== undefined;
|
|
268
|
+
if (e.keyCode === 13) {
|
|
269
|
+
if (isYearFocused && isPickable(active))
|
|
270
|
+
setYear(active.$year);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
e.preventDefault();
|
|
274
|
+
if (!isYearFocused) {
|
|
275
|
+
var target = cellOf(fp.selectedDates.length
|
|
276
|
+
? fp.selectedDates[0].getFullYear()
|
|
277
|
+
: new Date().getFullYear());
|
|
278
|
+
if (!target || target.classList.contains("flatpickr-disabled"))
|
|
279
|
+
target = self.yearsContainer.querySelector(".flatpickr-yearSelect-year:not(.flatpickr-disabled)");
|
|
280
|
+
if (target)
|
|
281
|
+
target.focus();
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
var year = clampYear(active.$year + shift);
|
|
285
|
+
if (year === active.$year)
|
|
286
|
+
return;
|
|
287
|
+
if (!cellOf(year))
|
|
288
|
+
fp.changeYear(year);
|
|
289
|
+
var cell = cellOf(year);
|
|
290
|
+
if (cell)
|
|
291
|
+
cell.focus();
|
|
292
|
+
}
|
|
293
|
+
function onOpen() {
|
|
294
|
+
fp.jumpToDate();
|
|
295
|
+
}
|
|
296
|
+
function closeHook() {
|
|
297
|
+
var _a;
|
|
298
|
+
if (((_a = fp.config) === null || _a === void 0 ? void 0 : _a.mode) === "range" && fp.selectedDates.length === 1)
|
|
299
|
+
fp.clear(false);
|
|
300
|
+
}
|
|
301
|
+
function destroyPluginInstance() {
|
|
302
|
+
if (self.yearsContainer !== null) {
|
|
303
|
+
var years = self.yearsContainer.querySelectorAll(".flatpickr-yearSelect-year");
|
|
304
|
+
for (var index = 0; index < years.length; index++) {
|
|
305
|
+
years[index].removeEventListener("click", selectYear);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
self.yearsContainer = null;
|
|
309
|
+
self.title = null;
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
disableMobile: true,
|
|
313
|
+
onParseConfig: function () {
|
|
314
|
+
fp.config.enableTime = false;
|
|
315
|
+
fp.config.noCalendar = false;
|
|
316
|
+
fp.config.weekNumbers = false;
|
|
317
|
+
fp.config.showMonths = 1;
|
|
318
|
+
},
|
|
319
|
+
onDaysBuilt: buildYears,
|
|
320
|
+
onOpen: onOpen,
|
|
321
|
+
onKeyDown: onKeyDown,
|
|
322
|
+
onReady: [
|
|
323
|
+
clearUnnecessaryDOMElements,
|
|
324
|
+
build,
|
|
325
|
+
bindEvents,
|
|
326
|
+
buildYears,
|
|
327
|
+
function () {
|
|
328
|
+
fp.config.onClose.push(closeHook);
|
|
329
|
+
fp.loadedPlugins.push("yearSelect");
|
|
330
|
+
},
|
|
331
|
+
],
|
|
332
|
+
onDestroy: [
|
|
333
|
+
destroyPluginInstance,
|
|
334
|
+
function () {
|
|
335
|
+
fp.config.onClose = fp.config.onClose.filter(function (hook) { return hook !== closeHook; });
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
export default yearSelectPlugin;
|
package/dist/esm/utils/dates.js
CHANGED
|
@@ -64,7 +64,7 @@ export var createDateParser = function (_a) {
|
|
|
64
64
|
var escaped = format[i - 1] === "\\" || isBackSlash;
|
|
65
65
|
if (tokenRegex[token] && !escaped) {
|
|
66
66
|
regexStr += tokenRegex[token];
|
|
67
|
-
var match = new RegExp(regexStr).exec(date);
|
|
67
|
+
var match = new RegExp(regexStr, "i").exec(date);
|
|
68
68
|
if (match && (matched = true)) {
|
|
69
69
|
ops[(_a = writeOrder[token]) !== null && _a !== void 0 ? _a : 2].push({
|
|
70
70
|
fn: revFormat[token],
|
|
@@ -148,7 +148,7 @@ export function getDefaultHours(config) {
|
|
|
148
148
|
if (hours === maxHr)
|
|
149
149
|
minutes = Math.min(maxMinutes, minutes);
|
|
150
150
|
if (hours === maxHr && minutes === maxMinutes)
|
|
151
|
-
seconds = config.maxDate.getSeconds();
|
|
151
|
+
seconds = Math.min(seconds, config.maxDate.getSeconds());
|
|
152
152
|
}
|
|
153
153
|
return { hours: hours, minutes: minutes, seconds: seconds };
|
|
154
154
|
}
|
|
@@ -1,30 +1,50 @@
|
|
|
1
1
|
import { int, pad } from "../utils";
|
|
2
2
|
var doNothing = function () { return undefined; };
|
|
3
3
|
export var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
|
|
4
|
+
var monthIndex = function (monthNames, monthName) {
|
|
5
|
+
return monthNames.map(function (name) { return name.toUpperCase(); }).indexOf(monthName.toUpperCase());
|
|
6
|
+
};
|
|
7
|
+
var invalidDate = function () { return new Date(NaN); };
|
|
8
|
+
var setInRange = function (min, max, set) { return function (dateObj, data) {
|
|
9
|
+
var value = parseFloat(data);
|
|
10
|
+
if (value < min || value > max)
|
|
11
|
+
return invalidDate();
|
|
12
|
+
set(dateObj, value);
|
|
13
|
+
}; };
|
|
14
|
+
var setDay = function (dateObj, day) {
|
|
15
|
+
var value = parseFloat(day);
|
|
16
|
+
dateObj.setDate(value);
|
|
17
|
+
if (dateObj.getDate() !== value)
|
|
18
|
+
return invalidDate();
|
|
19
|
+
};
|
|
20
|
+
var setMonth = setInRange(1, 12, function (dateObj, month) {
|
|
21
|
+
dateObj.setMonth(month - 1, 1);
|
|
22
|
+
});
|
|
23
|
+
var setHours = setInRange(0, 23, function (dateObj, hour) {
|
|
24
|
+
dateObj.setHours(hour);
|
|
25
|
+
});
|
|
26
|
+
var setHours12 = setInRange(0, 23, function (dateObj, hour) {
|
|
27
|
+
dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + hour);
|
|
28
|
+
});
|
|
29
|
+
var setSeconds = setInRange(0, 59, function (dateObj, seconds) {
|
|
30
|
+
dateObj.setSeconds(seconds);
|
|
31
|
+
});
|
|
4
32
|
export var revFormat = {
|
|
5
33
|
D: doNothing,
|
|
6
34
|
F: function (dateObj, monthName, locale) {
|
|
7
|
-
dateObj.setMonth(locale.months.longhand
|
|
8
|
-
},
|
|
9
|
-
G: function (dateObj, hour) {
|
|
10
|
-
dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour));
|
|
11
|
-
},
|
|
12
|
-
H: function (dateObj, hour) {
|
|
13
|
-
dateObj.setHours(parseFloat(hour));
|
|
14
|
-
},
|
|
15
|
-
J: function (dateObj, day) {
|
|
16
|
-
dateObj.setDate(parseFloat(day));
|
|
35
|
+
dateObj.setMonth(monthIndex(locale.months.longhand, monthName), 1);
|
|
17
36
|
},
|
|
37
|
+
G: setHours12,
|
|
38
|
+
H: setHours,
|
|
39
|
+
J: setDay,
|
|
18
40
|
K: function (dateObj, amPM, locale) {
|
|
19
41
|
dateObj.setHours((dateObj.getHours() % 12) +
|
|
20
42
|
12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
|
|
21
43
|
},
|
|
22
44
|
M: function (dateObj, shortMonth, locale) {
|
|
23
|
-
dateObj.setMonth(locale.months.shorthand
|
|
24
|
-
},
|
|
25
|
-
S: function (dateObj, seconds) {
|
|
26
|
-
dateObj.setSeconds(parseFloat(seconds));
|
|
45
|
+
dateObj.setMonth(monthIndex(locale.months.shorthand, shortMonth), 1);
|
|
27
46
|
},
|
|
47
|
+
S: setSeconds,
|
|
28
48
|
U: function (_, unixSeconds) { return new Date(parseFloat(unixSeconds) * 1000); },
|
|
29
49
|
W: function (dateObj, weekNum, locale) {
|
|
30
50
|
var weekNumber = parseInt(weekNum);
|
|
@@ -36,28 +56,16 @@ export var revFormat = {
|
|
|
36
56
|
dateObj.setFullYear(parseFloat(year));
|
|
37
57
|
},
|
|
38
58
|
Z: function (_, ISODate) { return new Date(ISODate); },
|
|
39
|
-
d:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
i: function (dateObj, minutes) {
|
|
46
|
-
dateObj.setMinutes(parseFloat(minutes));
|
|
47
|
-
},
|
|
48
|
-
j: function (dateObj, day) {
|
|
49
|
-
dateObj.setDate(parseFloat(day));
|
|
50
|
-
},
|
|
59
|
+
d: setDay,
|
|
60
|
+
h: setHours12,
|
|
61
|
+
i: setInRange(0, 59, function (dateObj, minutes) {
|
|
62
|
+
dateObj.setMinutes(minutes);
|
|
63
|
+
}),
|
|
64
|
+
j: setDay,
|
|
51
65
|
l: doNothing,
|
|
52
|
-
m:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
n: function (dateObj, month) {
|
|
56
|
-
dateObj.setMonth(parseFloat(month) - 1, 1);
|
|
57
|
-
},
|
|
58
|
-
s: function (dateObj, seconds) {
|
|
59
|
-
dateObj.setSeconds(parseFloat(seconds));
|
|
60
|
-
},
|
|
66
|
+
m: setMonth,
|
|
67
|
+
n: setMonth,
|
|
68
|
+
s: setSeconds,
|
|
61
69
|
u: function (_, unixMillSeconds) {
|
|
62
70
|
return new Date(parseFloat(unixMillSeconds));
|
|
63
71
|
},
|