@seafile/seafile-calendar 0.0.29-alpha.4 → 0.0.29-alpha12
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/dist/rc-calendar.css +1179 -0
- package/dist/rc-calendar.css.map +1 -0
- package/dist/rc-calendar.js +7588 -0
- package/dist/rc-calendar.js.map +1 -0
- package/dist/rc-calendar.min.css +1179 -0
- package/dist/rc-calendar.min.css.map +1 -0
- package/dist/rc-calendar.min.js +1 -0
- package/es/Calendar.js +8 -4
- package/es/Picker.js +1 -0
- package/es/calendar/CalendarRightPanel.js +17 -3
- package/es/date/DateInput.js +59 -43
- package/es/date/DateTHead.js +3 -2
- package/es/util/index.js +459 -0
- package/lib/Calendar.js +8 -4
- package/lib/Picker.js +1 -0
- package/lib/calendar/CalendarRightPanel.js +18 -3
- package/lib/date/DateInput.js +58 -42
- package/lib/date/DateTHead.js +3 -2
- package/lib/util/index.js +471 -0
- package/package.json +1 -1
package/lib/util/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
|
+
exports.DATE_FORMATS = exports.currentTime = exports.stringCurrentMonth = exports.stringCurrentDate = exports.currentYear = exports.currentMonth = exports.currentDate = undefined;
|
4
5
|
|
5
6
|
var _extends2 = require('babel-runtime/helpers/extends');
|
6
7
|
|
@@ -16,6 +17,17 @@ exports.isTimeValidByConfig = isTimeValidByConfig;
|
|
16
17
|
exports.isTimeValid = isTimeValid;
|
17
18
|
exports.isAllowedDate = isAllowedDate;
|
18
19
|
exports.formatDate = formatDate;
|
20
|
+
exports.formatDateLocal = formatDateLocal;
|
21
|
+
exports.hasSpecialChar = hasSpecialChar;
|
22
|
+
exports.isValidMonth = isValidMonth;
|
23
|
+
exports.isValidDay = isValidDay;
|
24
|
+
exports.fullValidYear = fullValidYear;
|
25
|
+
exports.delimate = delimate;
|
26
|
+
exports.getDateFormatByStr = getDateFormatByStr;
|
27
|
+
exports.isCurrentYear = isCurrentYear;
|
28
|
+
exports.validateTime = validateTime;
|
29
|
+
exports.checkSpecialBetweenDigits = checkSpecialBetweenDigits;
|
30
|
+
exports.normalizeDateInput = normalizeDateInput;
|
19
31
|
|
20
32
|
var _dayjs = require('dayjs');
|
21
33
|
|
@@ -28,6 +40,23 @@ var _utc2 = _interopRequireDefault(_utc);
|
|
28
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
29
41
|
|
30
42
|
_dayjs2['default'].extend(_utc2['default']);
|
43
|
+
var currentDate = exports.currentDate = (0, _dayjs2['default'])().date();
|
44
|
+
var currentMonth = exports.currentMonth = (0, _dayjs2['default'])().month() + 1;
|
45
|
+
var currentYear = exports.currentYear = (0, _dayjs2['default'])().year();
|
46
|
+
var stringCurrentDate = exports.stringCurrentDate = String(currentDate).padStart(2, '0');
|
47
|
+
var stringCurrentMonth = exports.stringCurrentMonth = String(currentMonth).padStart(2, '0');
|
48
|
+
var currentTime = exports.currentTime = (0, _dayjs2['default'])().format('HH:mm');
|
49
|
+
|
50
|
+
var DATE_FORMATS = exports.DATE_FORMATS = {
|
51
|
+
ISO: 'YYYY-MM-DD',
|
52
|
+
ISOAndTime: 'YYYY-MM-DD HH:mm',
|
53
|
+
US: 'M/D/YYYY',
|
54
|
+
USAndTime: 'M/D/YYYY HH:mm',
|
55
|
+
European: 'DD/MM/YYYY',
|
56
|
+
EuropeanAndTime: 'DD/MM/YYYY HH:mm',
|
57
|
+
Germany_Russia_etc: 'DD.MM.YYYY',
|
58
|
+
Germany_Russia_etcAndTime: 'DD.MM.YYYY HH:mm'
|
59
|
+
};
|
31
60
|
|
32
61
|
var defaultDisabledTime = {
|
33
62
|
disabledHours: function disabledHours() {
|
@@ -127,4 +156,446 @@ function formatDate(value, format) {
|
|
127
156
|
}
|
128
157
|
|
129
158
|
return value.format(format);
|
159
|
+
}
|
160
|
+
|
161
|
+
function formatDateLocal(formatStr, format) {
|
162
|
+
var str = formatStr || '';
|
163
|
+
var cleanStr = void 0;
|
164
|
+
switch (format) {
|
165
|
+
case DATE_FORMATS.ISO:
|
166
|
+
case DATE_FORMATS.ISOAndTime:
|
167
|
+
cleanStr = str.replace(/[^0-9]+/g, '-');
|
168
|
+
return cleanStr.split('-').filter(Boolean).map(String);
|
169
|
+
case DATE_FORMATS.US:
|
170
|
+
case DATE_FORMATS.USAndTime:
|
171
|
+
case DATE_FORMATS.European:
|
172
|
+
case DATE_FORMATS.EuropeanAndTime:
|
173
|
+
cleanStr = str.replace(/[^0-9]+/g, '/');
|
174
|
+
return cleanStr.split('/').filter(Boolean).map(String);
|
175
|
+
case DATE_FORMATS.Germany_Russia_etc:
|
176
|
+
case DATE_FORMATS.Germany_Russia_etcAndTime:
|
177
|
+
cleanStr = str.replace(/[^0-9]+/g, '.');
|
178
|
+
return cleanStr.split('.').filter(Boolean).map(String);
|
179
|
+
default:
|
180
|
+
return [];
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
function hasSpecialChar(str) {
|
185
|
+
var matches = str.match(/[^0-9]/g);
|
186
|
+
return matches ? matches.length : 0;
|
187
|
+
}
|
188
|
+
|
189
|
+
function isValidMonth(monthStr) {
|
190
|
+
if (typeof monthStr === 'undefined' || monthStr === null) return currentMonth;
|
191
|
+
if (!/^\d+$/.test(Number(monthStr))) return currentMonth;
|
192
|
+
var month = Number(monthStr);
|
193
|
+
if (month >= 1 && month <= 12) {
|
194
|
+
return monthStr;
|
195
|
+
}
|
196
|
+
return currentMonth;
|
197
|
+
}
|
198
|
+
|
199
|
+
function isValidDay(dayStr) {
|
200
|
+
if (!/^\d+$/.test(dayStr)) return false;
|
201
|
+
var day = Number(dayStr);
|
202
|
+
if ([1, 3, 5, 7, 8, 10, 12].includes(currentMonth)) {
|
203
|
+
return day >= 1 && day <= 31;
|
204
|
+
}
|
205
|
+
if ([4, 6, 9, 11].includes(currentMonth)) {
|
206
|
+
return day >= 1 && day <= 30;
|
207
|
+
}
|
208
|
+
if (currentMonth === 2) {
|
209
|
+
var isLeapYear = function isLeapYear(year) {
|
210
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
211
|
+
};
|
212
|
+
var year = currentYear;
|
213
|
+
if (isLeapYear(year)) {
|
214
|
+
return day >= 1 && day <= 29;
|
215
|
+
}
|
216
|
+
return day >= 1 && day <= 28;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
function fullValidYear(yearStr) {
|
221
|
+
var year = yearStr;
|
222
|
+
if (!year || isNaN(year)) return currentYear;
|
223
|
+
if (year.length === 2) {
|
224
|
+
if (Number(year) >= 0 && Number(year) < 69) {
|
225
|
+
return year ? '20' + year : currentYear;
|
226
|
+
} else if (Number(year) >= 69 && Number(year) < 100) {
|
227
|
+
return year ? '19' + year : currentYear;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
if (year.length === 4) {
|
231
|
+
return year;
|
232
|
+
}
|
233
|
+
return year ? year.padStart(4, '0') : currentYear;
|
234
|
+
}
|
235
|
+
|
236
|
+
function delimate(formatPrefix) {
|
237
|
+
var delimiter = void 0;
|
238
|
+
if (formatPrefix === DATE_FORMATS.Germany_Russia_etc || formatPrefix === DATE_FORMATS.Germany_Russia_etcAndTime) {
|
239
|
+
delimiter = '.';
|
240
|
+
} else if (formatPrefix === DATE_FORMATS.ISO || formatPrefix === DATE_FORMATS.ISOAndTime) {
|
241
|
+
delimiter = '-';
|
242
|
+
} else {
|
243
|
+
delimiter = '/';
|
244
|
+
}
|
245
|
+
return delimiter;
|
246
|
+
}
|
247
|
+
|
248
|
+
function getDateFormatByStr(str, format) {
|
249
|
+
var cananderStr = str || '';
|
250
|
+
var delimiter = delimate(format);
|
251
|
+
var parts = cananderStr.split(delimiter);
|
252
|
+
if (parts.length !== 3) return format;
|
253
|
+
if (format === DATE_FORMATS.ISO) {
|
254
|
+
return DATE_FORMATS.ISO;
|
255
|
+
}
|
256
|
+
if (format === DATE_FORMATS.ISOAndTime) {
|
257
|
+
return DATE_FORMATS.ISOAndTime;
|
258
|
+
}
|
259
|
+
if (format === DATE_FORMATS.US) {
|
260
|
+
return DATE_FORMATS.US;
|
261
|
+
}
|
262
|
+
if (format === DATE_FORMATS.USAndTime) {
|
263
|
+
return DATE_FORMATS.USAndTime;
|
264
|
+
}
|
265
|
+
if (format === DATE_FORMATS.European || format === DATE_FORMATS.Germany_Russia_etc) {
|
266
|
+
var day = parts[0],
|
267
|
+
month = parts[1];
|
268
|
+
|
269
|
+
var dayLen = day.length;
|
270
|
+
var monthLen = month.length;
|
271
|
+
if (dayLen === 2 && monthLen === 2) {
|
272
|
+
return 'DD' + delimiter + 'MM' + delimiter + 'YYYY';
|
273
|
+
} else if (dayLen === 2 && monthLen === 1) {
|
274
|
+
return 'DD' + delimiter + 'M' + delimiter + 'YYYY';
|
275
|
+
} else if (dayLen === 1 && monthLen === 2) {
|
276
|
+
return 'D' + delimiter + 'MM' + delimiter + 'YYYY';
|
277
|
+
} else if (dayLen === 1 && monthLen === 1) {
|
278
|
+
return 'D' + delimiter + 'M' + delimiter + 'YYYY';
|
279
|
+
}
|
280
|
+
}
|
281
|
+
if (format === DATE_FORMATS.EuropeanAndTime || format === DATE_FORMATS.Germany_Russia_etcAndTime) {
|
282
|
+
var _day = parts[0],
|
283
|
+
_month = parts[1];
|
284
|
+
|
285
|
+
var _dayLen = _day.length;
|
286
|
+
var _monthLen = _month.length;
|
287
|
+
if (_dayLen === 2 && _monthLen === 2) {
|
288
|
+
return 'DD' + delimiter + 'MM' + delimiter + 'YYYY HH:mm';
|
289
|
+
} else if (_dayLen === 2 && _monthLen === 1) {
|
290
|
+
return 'DD' + delimiter + 'M' + delimiter + 'YYYY HH:mm';
|
291
|
+
} else if (_dayLen === 1 && _monthLen === 2) {
|
292
|
+
return 'D' + delimiter + 'MM' + delimiter + 'YYYY HH:mm';
|
293
|
+
} else if (_dayLen === 1 && _monthLen === 1) {
|
294
|
+
return 'D' + delimiter + 'M' + delimiter + 'YYYY HH:mm';
|
295
|
+
}
|
296
|
+
}
|
297
|
+
return format;
|
298
|
+
}
|
299
|
+
|
300
|
+
function isCurrentYear(year, month, day) {
|
301
|
+
return Number(month) >= 1 && Number(month) <= 12 && Number(day) >= 1 && Number(day) <= 31 ? year : currentYear; // eslint-disable-line max-len
|
302
|
+
}
|
303
|
+
|
304
|
+
function validateTime(inputTime) {
|
305
|
+
if (!inputTime || typeof inputTime !== 'string') {
|
306
|
+
return currentTime;
|
307
|
+
}
|
308
|
+
var trimmed = inputTime.trim();
|
309
|
+
var timeRegex = /^(\d{2}):(\d{2})$/;
|
310
|
+
var match = trimmed.match(timeRegex);
|
311
|
+
if (!match) {
|
312
|
+
return currentTime;
|
313
|
+
}
|
314
|
+
var hour = Number(match[1]);
|
315
|
+
var minute = Number(match[2]);
|
316
|
+
if (hour > 23 || minute > 59) {
|
317
|
+
return currentTime;
|
318
|
+
}
|
319
|
+
return match[1] + ':' + match[2];
|
320
|
+
}
|
321
|
+
|
322
|
+
function checkSpecialBetweenDigits(str) {
|
323
|
+
var regex = /^\d+[^0-9]\d+$/;
|
324
|
+
return regex.test(str);
|
325
|
+
}
|
326
|
+
|
327
|
+
function getDatePart(str) {
|
328
|
+
if (typeof str !== 'string') return '';
|
329
|
+
var parts = str.trim().split(/\s+/);
|
330
|
+
return parts[0];
|
331
|
+
}
|
332
|
+
|
333
|
+
function normalizeDateInput(str, localeFormat, delimiter) {
|
334
|
+
var day = void 0;
|
335
|
+
var month = void 0;
|
336
|
+
var year = void 0;
|
337
|
+
var time = currentTime;
|
338
|
+
var parts = formatDateLocal(str, localeFormat, DATE_FORMATS);
|
339
|
+
if (localeFormat === DATE_FORMATS.ISO) {
|
340
|
+
var hasSpecial = hasSpecialChar(str);
|
341
|
+
var numStr = str.replace(/[^0-9]/g, '');
|
342
|
+
if (numStr.length === 7) {
|
343
|
+
year = numStr.slice(0, 4);
|
344
|
+
month = numStr.slice(4, 6).padStart(2, '0');
|
345
|
+
day = numStr.slice(6, 7).padStart(2, '0');
|
346
|
+
if (!isValidDay(day)) {
|
347
|
+
return year + '-' + stringCurrentMonth + '-' + stringCurrentDate;
|
348
|
+
}
|
349
|
+
return year + '-' + month + '-' + day;
|
350
|
+
}
|
351
|
+
if (hasSpecial) {
|
352
|
+
year = fullValidYear(parts[0]);
|
353
|
+
month = Number(parts[1]);
|
354
|
+
day = Number(parts[2]);
|
355
|
+
if (month >= 1 && month <= 12) {
|
356
|
+
if (isValidDay(day)) {
|
357
|
+
return year + '-' + String(month).padStart(2, '0') + '-' + String(day).padStart(2, '0');
|
358
|
+
}
|
359
|
+
return year + '-' + String(month).padStart(2, '0') + '-01';
|
360
|
+
}
|
361
|
+
if ((month >= 13 || month < 1) && isNaN(day)) {
|
362
|
+
return year + '-' + stringCurrentMonth + '-' + stringCurrentDate;
|
363
|
+
}
|
364
|
+
if ((month >= 13 || month < 1) && day) {
|
365
|
+
return String(currentYear) + '-' + stringCurrentMonth + '-' + stringCurrentDate;
|
366
|
+
}
|
367
|
+
if (!month && !day) {
|
368
|
+
return year + '-01-01';
|
369
|
+
}
|
370
|
+
}
|
371
|
+
if (str.length >= 1 && str.length <= 8) {
|
372
|
+
year = fullValidYear(str.slice(0, 4));
|
373
|
+
month = str.slice(4, 6);
|
374
|
+
day = Number(str.slice(6, 8));
|
375
|
+
if (str.length === 5 && Number(month) < 1) {
|
376
|
+
return year + '-' + stringCurrentMonth + '-' + stringCurrentDate + ' ';
|
377
|
+
}
|
378
|
+
if (str.length === 6 && Number(month) < 1) {
|
379
|
+
return year + '-' + stringCurrentMonth + '-' + stringCurrentDate;
|
380
|
+
}
|
381
|
+
if (str.length === 7) {
|
382
|
+
if (!isValidDay(day)) {
|
383
|
+
return year + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + stringCurrentDate;
|
384
|
+
}
|
385
|
+
return year + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + String(day).padStart(2, '0'); // eslint-disable-line max-len
|
386
|
+
}
|
387
|
+
if (str.length === 8) {
|
388
|
+
if (!isValidDay(day)) {
|
389
|
+
return isCurrentYear(year, month, day) + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + stringCurrentDate; // eslint-disable-line max-len
|
390
|
+
}
|
391
|
+
return isCurrentYear(year, month, day) + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + String(day).padStart(2, '0'); // eslint-disable-line max-len
|
392
|
+
}
|
393
|
+
if (Number(month) >= 1 && Number(month) <= 12 && isValidDay(day)) {
|
394
|
+
return year + '-' + month.padStart(2, '0') + '-' + String(day).padStart(2, '0');
|
395
|
+
}
|
396
|
+
return year + '-' + (month ? month.padStart(2, '0') : '01') + '-' + (day ? String(day).padStart(2, '0') : '01'); // eslint-disable-line max-len
|
397
|
+
}
|
398
|
+
return currentYear + '/' + stringCurrentMonth + '/' + stringCurrentDate;
|
399
|
+
}
|
400
|
+
if (localeFormat === DATE_FORMATS.ISOAndTime) {
|
401
|
+
var unNormalDate = getDatePart(str);
|
402
|
+
var unNormalDateParts = formatDateLocal(unNormalDate, localeFormat, DATE_FORMATS);
|
403
|
+
var _hasSpecial = hasSpecialChar(unNormalDate);
|
404
|
+
var _numStr = unNormalDate.replace(/[^0-9]/g, '');
|
405
|
+
if (_numStr.length === 7) {
|
406
|
+
year = _numStr.slice(0, 4);
|
407
|
+
month = _numStr.slice(4, 6).padStart(2, '0');
|
408
|
+
day = _numStr.slice(6, 7).padStart(2, '0');
|
409
|
+
if (parts.length === 3) {
|
410
|
+
time = validateTime(parts[1] + ':' + parts[2]);
|
411
|
+
}
|
412
|
+
if (parts.length === 4) {
|
413
|
+
time = validateTime(parts[2] + ':' + parts[3]);
|
414
|
+
}
|
415
|
+
if (parts.length === 5) {
|
416
|
+
time = validateTime(parts[3] + ':' + parts[4]);
|
417
|
+
}
|
418
|
+
if (!isValidDay(day)) {
|
419
|
+
return year + '-' + stringCurrentMonth + '-' + stringCurrentDate + ' ' + time;
|
420
|
+
}
|
421
|
+
return year + '-' + month + '-' + day + ' ' + time;
|
422
|
+
}
|
423
|
+
if (_hasSpecial) {
|
424
|
+
if (unNormalDateParts.length < 3) {
|
425
|
+
parts.splice(2, 0, '1');
|
426
|
+
}
|
427
|
+
year = fullValidYear(parts[0]);
|
428
|
+
month = Number(parts[1]);
|
429
|
+
day = Number(parts[2]);
|
430
|
+
time = validateTime(parts[3] + ':' + parts[4]);
|
431
|
+
if (month >= 1 && month <= 12) {
|
432
|
+
if (isValidDay(day)) {
|
433
|
+
return year + '-' + String(month).padStart(2, '0') + '-' + String(day).padStart(2, '0') + ' ' + time; // eslint-disable-line max-len
|
434
|
+
}
|
435
|
+
return year + '-' + String(month).padStart(2, '0') + '-01 ' + time;
|
436
|
+
}
|
437
|
+
if ((month >= 13 || month < 1) && isNaN(day)) {
|
438
|
+
return year + '-' + stringCurrentMonth + '-' + stringCurrentDate + ' ' + time; // eslint-disable-line max-len
|
439
|
+
}
|
440
|
+
if ((month >= 13 || month < 1) && day) {
|
441
|
+
return String(currentYear) + '-' + stringCurrentMonth + '-' + stringCurrentDate + ' ' + time; // eslint-disable-line max-len
|
442
|
+
}
|
443
|
+
if (!month && !day) {
|
444
|
+
return year + '-01-01 ' + time;
|
445
|
+
}
|
446
|
+
}
|
447
|
+
if (unNormalDate.length >= 1 && unNormalDate.length <= 8) {
|
448
|
+
year = fullValidYear(unNormalDate.slice(0, 4));
|
449
|
+
month = unNormalDate.slice(4, 6);
|
450
|
+
day = Number(unNormalDate.slice(6, 8));
|
451
|
+
var timeParts = formatDateLocal(str, localeFormat, DATE_FORMATS);
|
452
|
+
time = validateTime(timeParts[1] + ':' + timeParts[2]);
|
453
|
+
if (unNormalDate.length === 5 && Number(month) < 1) {
|
454
|
+
return year + '-' + stringCurrentMonth + '-' + stringCurrentDate + ' ' + time;
|
455
|
+
}
|
456
|
+
if (unNormalDate.length === 6 && Number(month) < 1) {
|
457
|
+
return year + '-' + stringCurrentMonth + '-' + stringCurrentDate + ' ' + time;
|
458
|
+
}
|
459
|
+
if (unNormalDate.length === 7) {
|
460
|
+
if (!isValidDay(day)) {
|
461
|
+
return year + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + stringCurrentDate + ' ' + time; // eslint-disable-line max-len
|
462
|
+
}
|
463
|
+
return year + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + String(day).padStart(2, '0') + ' ' + time; // eslint-disable-line max-len
|
464
|
+
}
|
465
|
+
if (unNormalDate.length === 8) {
|
466
|
+
if (!isValidDay(day)) {
|
467
|
+
return isCurrentYear(year, month, day) + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + stringCurrentDate + ' ' + time; // eslint-disable-line max-len
|
468
|
+
}
|
469
|
+
return isCurrentYear(year, month, day) + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + String(day).padStart(2, '0') + ' ' + time; // eslint-disable-line max-len
|
470
|
+
}
|
471
|
+
if (Number(month) >= 1 && Number(month) <= 12 && isValidDay(day)) {
|
472
|
+
return year + '-' + month.padStart(2, '0') + '-' + String(day).padStart(2, '0') + ' ' + time;
|
473
|
+
}
|
474
|
+
return year + '-' + (month ? month.padStart(2, '0') : '01') + '-' + (day ? String(day).padStart(2, '0') : '01') + ' ' + time; // eslint-disable-line max-len
|
475
|
+
}
|
476
|
+
return currentYear + '/' + stringCurrentMonth + '/' + stringCurrentDate + ' ' + time;
|
477
|
+
}
|
478
|
+
if (localeFormat === DATE_FORMATS.US) {
|
479
|
+
var _hasSpecial2 = hasSpecialChar(str);
|
480
|
+
if (_hasSpecial2) {
|
481
|
+
month = Number(parts[0]);
|
482
|
+
day = Number(parts[1]);
|
483
|
+
year = fullValidYear(parts[2]);
|
484
|
+
if (month >= 1 && month <= 12 && isValidDay(day)) {
|
485
|
+
return month + '/' + day + '/' + year;
|
486
|
+
}
|
487
|
+
return currentMonth + '/' + currentDate + '/' + currentYear;
|
488
|
+
}
|
489
|
+
if (str.length >= 1 && str.length <= 8) {
|
490
|
+
month = Number(str.slice(0, 2));
|
491
|
+
day = Number(str.slice(2, 4));
|
492
|
+
year = fullValidYear(str.slice(4, str.length));
|
493
|
+
if (month >= 1 && month <= 12) {
|
494
|
+
if (isValidDay(day)) {
|
495
|
+
return month + '/' + day + '/' + year;
|
496
|
+
}
|
497
|
+
if (!day) {
|
498
|
+
return month + '/1/' + year;
|
499
|
+
}
|
500
|
+
return currentMonth + '/' + currentDate + '/' + currentYear;
|
501
|
+
}
|
502
|
+
}
|
503
|
+
return currentMonth + '/' + currentDate + '/' + currentYear;
|
504
|
+
}
|
505
|
+
if (localeFormat === DATE_FORMATS.USAndTime) {
|
506
|
+
var _unNormalDate = getDatePart(str);
|
507
|
+
var _unNormalDateParts = formatDateLocal(_unNormalDate, localeFormat, DATE_FORMATS);
|
508
|
+
var _hasSpecial3 = hasSpecialChar(_unNormalDate);
|
509
|
+
if (_hasSpecial3) {
|
510
|
+
if (_unNormalDateParts.length < 3) {
|
511
|
+
parts.splice(2, 0, String(currentYear));
|
512
|
+
}
|
513
|
+
month = Number(parts[0]);
|
514
|
+
day = Number(parts[1]);
|
515
|
+
year = fullValidYear(parts[2]);
|
516
|
+
time = validateTime(parts[3] + ':' + parts[4]);
|
517
|
+
if (month >= 1 && month <= 12 && isValidDay(day)) {
|
518
|
+
return month + '/' + day + '/' + year + ' ' + time;
|
519
|
+
}
|
520
|
+
return currentMonth + '/' + currentDate + '/' + currentYear + ' ' + time;
|
521
|
+
}
|
522
|
+
if (_unNormalDate.length >= 1 && _unNormalDate.length <= 8) {
|
523
|
+
month = Number(_unNormalDate.slice(0, 2));
|
524
|
+
day = Number(_unNormalDate.slice(2, 4));
|
525
|
+
year = fullValidYear(_unNormalDate.slice(4, _unNormalDate.length));
|
526
|
+
var _timeParts = formatDateLocal(str, localeFormat, DATE_FORMATS);
|
527
|
+
time = validateTime(_timeParts[1] + ':' + _timeParts[2]);
|
528
|
+
if (month >= 1 && month <= 12) {
|
529
|
+
if (isValidDay(day)) {
|
530
|
+
return month + '/' + day + '/' + year + ' ' + time;
|
531
|
+
}
|
532
|
+
if (!day) {
|
533
|
+
return month + '/1/' + year + ' ' + time;
|
534
|
+
}
|
535
|
+
return currentMonth + '/' + currentDate + '/' + currentYear + ' ' + time;
|
536
|
+
}
|
537
|
+
}
|
538
|
+
return currentMonth + '/' + currentDate + '/' + currentYear + ' ' + time;
|
539
|
+
}
|
540
|
+
if (localeFormat === DATE_FORMATS.European || localeFormat === DATE_FORMATS.Germany_Russia_etc) {
|
541
|
+
var _hasSpecial4 = hasSpecialChar(str);
|
542
|
+
if (_hasSpecial4) {
|
543
|
+
day = parts[0];
|
544
|
+
month = parts[1];
|
545
|
+
year = fullValidYear(parts[2]);
|
546
|
+
if (isValidDay(day) && Number(month) >= 1 && Number(month) <= 12) {
|
547
|
+
return '' + Number(day) + delimiter + Number(month) + delimiter + year;
|
548
|
+
}
|
549
|
+
return '' + currentDate + delimiter + currentMonth + delimiter + currentYear;
|
550
|
+
}
|
551
|
+
if (str.length >= 1 && str.length <= 8) {
|
552
|
+
day = Number(str.slice(0, 2));
|
553
|
+
var monthStr = str.slice(2, 4);
|
554
|
+
month = isValidMonth(monthStr);
|
555
|
+
var yearStr = str.slice(4, str.length);
|
556
|
+
year = fullValidYear(yearStr);
|
557
|
+
|
558
|
+
if (isValidDay(day)) {
|
559
|
+
if (Number(monthStr) < 1 && Number(monthStr) > 12) {
|
560
|
+
return '' + currentDate + delimiter + currentMonth + delimiter + currentYear;
|
561
|
+
}
|
562
|
+
return '' + Number(day) + delimiter + Number(month) + delimiter + year;
|
563
|
+
}
|
564
|
+
}
|
565
|
+
return '' + currentDate + delimiter + currentMonth + delimiter + currentYear;
|
566
|
+
}
|
567
|
+
if (localeFormat === DATE_FORMATS.EuropeanAndTime || localeFormat === DATE_FORMATS.Germany_Russia_etcAndTime) {
|
568
|
+
var _unNormalDate2 = getDatePart(str);
|
569
|
+
var _unNormalDateParts2 = formatDateLocal(_unNormalDate2, localeFormat, DATE_FORMATS);
|
570
|
+
var _hasSpecial5 = hasSpecialChar(_unNormalDate2);
|
571
|
+
if (_hasSpecial5) {
|
572
|
+
if (_unNormalDateParts2.length < 3) {
|
573
|
+
parts.splice(2, 0, String(currentYear));
|
574
|
+
}
|
575
|
+
day = parts[0];
|
576
|
+
month = parts[1];
|
577
|
+
year = fullValidYear(parts[2]);
|
578
|
+
time = validateTime(parts[3] + ':' + parts[4]);
|
579
|
+
if (isValidDay(day) && Number(month) >= 1 && Number(month) <= 12) {
|
580
|
+
return '' + Number(day) + delimiter + Number(month) + delimiter + year + ' ' + time;
|
581
|
+
}
|
582
|
+
return '' + currentDate + delimiter + currentMonth + delimiter + currentYear + ' ' + time;
|
583
|
+
}
|
584
|
+
if (_unNormalDate2.length >= 1 && _unNormalDate2.length <= 8) {
|
585
|
+
day = Number(_unNormalDate2.slice(0, 2));
|
586
|
+
var _monthStr = _unNormalDate2.slice(2, 4);
|
587
|
+
month = isValidMonth(_monthStr);
|
588
|
+
var _yearStr = _unNormalDate2.slice(4, _unNormalDate2.length);
|
589
|
+
year = fullValidYear(_yearStr);
|
590
|
+
var _timeParts2 = formatDateLocal(str, localeFormat, DATE_FORMATS);
|
591
|
+
time = validateTime(_timeParts2[1] + ':' + _timeParts2[2]);
|
592
|
+
if (isValidDay(day)) {
|
593
|
+
if (Number(_monthStr) < 1 && Number(_monthStr) > 12) {
|
594
|
+
return '' + currentDate + delimiter + currentMonth + delimiter + currentYear + ' ' + time;
|
595
|
+
}
|
596
|
+
return '' + Number(day) + delimiter + Number(month) + delimiter + year + ' ' + time;
|
597
|
+
}
|
598
|
+
}
|
599
|
+
return '' + currentDate + delimiter + currentMonth + delimiter + currentYear + ' ' + time;
|
600
|
+
}
|
130
601
|
}
|