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
src/components/date-picker/util.js
1 | 1 | import dateUtil from '../../utils/date'; |
2 | 2 | |
3 | 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 | 17 | export const formatDate = function(date, format) { | ... | ... |