Merge pull request #1760 from SergioCrisostomo/make-babel-transpile-ie-friendly

Make date more IE friendly
This commit is contained in:
Aresn 2017-09-01 10:11:26 +08:00 committed by GitHub
commit 66728edaec
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) {