Commit 58ff14d782e940ac620794782ff5f00bca991234
1 parent
8a4f9d5a
Make date more IE friendly
Showing
3 changed files
with
13 additions
and
4 deletions
Show diff stats
package.json
@@ -41,7 +41,7 @@ | @@ -41,7 +41,7 @@ | ||
41 | }, | 41 | }, |
42 | "dependencies": { | 42 | "dependencies": { |
43 | "async-validator": "^1.7.1", | 43 | "async-validator": "^1.7.1", |
44 | - "core-js": "^2.4.1", | 44 | + "core-js": "^2.5.0", |
45 | "deepmerge": "^1.5.0", | 45 | "deepmerge": "^1.5.0", |
46 | "popper.js": "^0.6.4", | 46 | "popper.js": "^0.6.4", |
47 | "tinycolor2": "^1.4.1" | 47 | "tinycolor2": "^1.4.1" |
src/components/date-picker/util.js
1 | import dateUtil from '../../utils/date'; | 1 | import dateUtil from '../../utils/date'; |
2 | 2 | ||
3 | export const toDate = function(date) { | 3 | export const toDate = function(date) { |
4 | - date = new Date(date); | ||
5 | - if (isNaN(date.getTime())) return null; | ||
6 | - return date; | 4 | + let _date = new Date(date); |
5 | + // IE patch start (#1422) | ||
6 | + if (isNaN(_date.getTime()) && typeof date === 'string'){ | ||
7 | + _date = date.split('-').map(Number); | ||
8 | + _date[1] += 1; | ||
9 | + _date = new Date(..._date); | ||
10 | + } | ||
11 | + // IE patch end | ||
12 | + | ||
13 | + if (isNaN(_date.getTime())) return null; | ||
14 | + return _date; | ||
7 | }; | 15 | }; |
8 | 16 | ||
9 | export const formatDate = function(date, format) { | 17 | export const formatDate = function(date, format) { |