Make date more IE friendly
This commit is contained in:
parent
8a4f9d5af3
commit
58ff14d782
3 changed files with 13 additions and 4 deletions
|
@ -1,9 +1,17 @@
|
|||
import dateUtil from '../../utils/date';
|
||||
|
||||
export const toDate = function(date) {
|
||||
date = new Date(date);
|
||||
if (isNaN(date.getTime())) return null;
|
||||
return date;
|
||||
let _date = new Date(date);
|
||||
// IE patch start (#1422)
|
||||
if (isNaN(_date.getTime()) && typeof date === 'string'){
|
||||
_date = date.split('-').map(Number);
|
||||
_date[1] += 1;
|
||||
_date = new Date(..._date);
|
||||
}
|
||||
// IE patch end
|
||||
|
||||
if (isNaN(_date.getTime())) return null;
|
||||
return _date;
|
||||
};
|
||||
|
||||
export const formatDate = function(date, format) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue