MCPcopy Create free account
hub / github.com/JacksonTian/fks / jsonStringToDate

Function jsonStringToDate

fks_chart/bower_components/angular/angular.js:15348–15370  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

15346 var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
15347 // 1 2 3 4 5 6 7 8 9 10 11
15348 function jsonStringToDate(string) {
15349 var match;
15350 if (match = string.match(R_ISO8601_STR)) {
15351 var date = new Date(0),
15352 tzHour = 0,
15353 tzMin = 0,
15354 dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,
15355 timeSetter = match[8] ? date.setUTCHours : date.setHours;
15356
15357 if (match[9]) {
15358 tzHour = int(match[9] + match[10]);
15359 tzMin = int(match[9] + match[11]);
15360 }
15361 dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3]));
15362 var h = int(match[4]||0) - tzHour;
15363 var m = int(match[5]||0) - tzMin;
15364 var s = int(match[6]||0);
15365 var ms = Math.round(parseFloat('0.' + (match[7]||0)) * 1000);
15366 timeSetter.call(date, h, m, s, ms);
15367 return date;
15368 }
15369 return string;
15370 }
15371
15372
15373 return function(date, format) {

Callers 1

dateFilterFunction · 0.85

Calls 1

intFunction · 0.85

Tested by

no test coverage detected