Skip to content

Commit 6a20794

Browse files
committed
refactor: simplify parseDate
1 parent b2939cd commit 6a20794

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

src/utils/index.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -181,29 +181,7 @@ const inherits = function inherits(parent, protoProps, staticProps) {
181181
return child;
182182
};
183183

184-
function parseDate(iso8601) {
185-
var regexp = new RegExp(
186-
'^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})' +
187-
'T' +
188-
'([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})' +
189-
'(.([0-9]+))?' +
190-
'Z$'
191-
);
192-
var match = regexp.exec(iso8601);
193-
if (!match) {
194-
return null;
195-
}
196-
197-
var year = match[1] || 0;
198-
var month = (match[2] || 1) - 1;
199-
var day = match[3] || 0;
200-
var hour = match[4] || 0;
201-
var minute = match[5] || 0;
202-
var second = match[6] || 0;
203-
var milli = match[8] || 0;
204-
205-
return new Date(Date.UTC(year, month, day, hour, minute, second, milli));
206-
}
184+
const parseDate = iso8601 => new Date(iso8601);
207185

208186
const setValue = (target, key, value) => {
209187
// '.' is not allowed in Class keys, escaping is not in concern now.

0 commit comments

Comments
 (0)