MCPcopy Create free account
hub / github.com/binux/qiandao / jsonStringToDate

Function jsonStringToDate

web/static/components/angularjs/angular.js:15166–15188  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

15164 var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
15165 // 1 2 3 4 5 6 7 8 9 10 11
15166 function jsonStringToDate(string) {
15167 var match;
15168 if (match = string.match(R_ISO8601_STR)) {
15169 var date = new Date(0),
15170 tzHour = 0,
15171 tzMin = 0,
15172 dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,
15173 timeSetter = match[8] ? date.setUTCHours : date.setHours;
15174
15175 if (match[9]) {
15176 tzHour = int(match[9] + match[10]);
15177 tzMin = int(match[9] + match[11]);
15178 }
15179 dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3]));
15180 var h = int(match[4]||0) - tzHour;
15181 var m = int(match[5]||0) - tzMin;
15182 var s = int(match[6]||0);
15183 var ms = Math.round(parseFloat('0.' + (match[7]||0)) * 1000);
15184 timeSetter.call(date, h, m, s, ms);
15185 return date;
15186 }
15187 return string;
15188 }
15189
15190
15191 return function(date, format) {

Callers 1

dateFilterFunction · 0.85

Calls 1

intFunction · 0.85

Tested by

no test coverage detected