parseDateTime() fix coding error
This commit is contained in:
+10
-5
@@ -132,7 +132,7 @@ function parseTime(t) {
|
||||
hour = isPM && hour < 12 ? hour + 12 : hour;
|
||||
return ('0' + hour).substr(-2) + ':' + ('0' + min).substr(-2);
|
||||
}
|
||||
let parts = t.split('.');
|
||||
parts = t.split('.');
|
||||
if (parts.length >= 2) {
|
||||
let isPM = (parts[1] && (parts[1].toLowerCase().indexOf('pm') > -1) || (parts[1].toLowerCase().indexOf('p.m.') > -1) || (parts[1].toLowerCase().indexOf('p. m.') > -1) || (parts[1].toLowerCase().indexOf('n') > -1) || (parts[1].toLowerCase().indexOf('ch') > -1) || (parts[1].toLowerCase().indexOf('ös') > -1));
|
||||
hour = parseInt(parts[0], 10);
|
||||
@@ -140,7 +140,7 @@ function parseTime(t) {
|
||||
hour = isPM && hour < 12 ? hour + 12 : hour;
|
||||
return ('0' + hour).substr(-2) + ':' + ('0' + min).substr(-2);
|
||||
}
|
||||
let parts = t.split(' ');
|
||||
parts = t.split(' ');
|
||||
if (parts.length >= 2) {
|
||||
let isPM = ((t.toLowerCase().indexOf('pm') > -1) || (t.toLowerCase().indexOf('p.m.') > -1) || (t.toLowerCase().indexOf('p. m.') > -1) || (t.toLowerCase().indexOf('n') > -1) || (t.toLowerCase().indexOf('ch') > -1) || (t.toLowerCase().indexOf('ös') > -1));
|
||||
hour = parseInt(parts[0], 10);
|
||||
@@ -173,8 +173,14 @@ function parseDateTime(dt) {
|
||||
result.date = '20' + dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2);
|
||||
} else {
|
||||
// Dateformat: mm/dd/yyyy or dd/mm/yyyy
|
||||
result.date = dtparts[2] + '-' + ('0' + dtparts[0]).substr(-2) + '-' + ('0' + dtparts[1]).substr(-2);
|
||||
|
||||
const isEN = ((dt.toLowerCase().indexOf('pm') > -1) || (dt.toLowerCase().indexOf('p.m.') > -1) || (dt.toLowerCase().indexOf('p. m.') > -1) || (dt.toLowerCase().indexOf('am') > -1) || (dt.toLowerCase().indexOf('a.m.') > -1) || (dt.toLowerCase().indexOf('a. m.') > -1));
|
||||
if (isEN) {
|
||||
// Dateformat: mm/dd/yyyy
|
||||
result.date = dtparts[2] + '-' + ('0' + dtparts[0]).substr(-2) + '-' + ('0' + dtparts[1]).substr(-2);
|
||||
} else {
|
||||
// Dateformat: dd/mm/yyyy
|
||||
result.date = dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,7 +193,6 @@ function parseDateTime(dt) {
|
||||
}
|
||||
if (parts[0].indexOf('-') >= 0) {
|
||||
// Dateformat: yyyy-mm-dd
|
||||
const isEN = ((dt.toLowerCase().indexOf('pm') > -1) || (t.toLowerCase().indexOf('p.m.') > -1) || (t.toLowerCase().indexOf('p. m.') > -1) || (dt.toLowerCase().indexOf('am') > -1) || (t.toLowerCase().indexOf('a.m.') > -1) || (t.toLowerCase().indexOf('a. m.') > -1));
|
||||
const dtparts = parts[0].split('-');
|
||||
if (dtparts.length === 3) {
|
||||
result.date = dtparts[0] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[2]).substr(-2);
|
||||
|
||||
Reference in New Issue
Block a user