Make date more IE friendly

This commit is contained in:
Sergio Crisostomo 2017-08-31 16:45:22 +02:00
parent 8a4f9d5af3
commit 58ff14d782
3 changed files with 13 additions and 4 deletions

View file

@ -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) {