Make date more IE friendly
This commit is contained in:
parent
8a4f9d5af3
commit
58ff14d782
3 changed files with 13 additions and 4 deletions
|
@ -41,7 +41,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"async-validator": "^1.7.1",
|
||||
"core-js": "^2.4.1",
|
||||
"core-js": "^2.5.0",
|
||||
"deepmerge": "^1.5.0",
|
||||
"popper.js": "^0.6.4",
|
||||
"tinycolor2": "^1.4.1"
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// es6 polyfill
|
||||
import 'core-js/fn/array/find';
|
||||
import 'core-js/fn/array/find-index';
|
||||
|
||||
import Affix from './components/affix';
|
||||
|
|
Loading…
Add table
Reference in a new issue