MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / jsonStringToDate

Function jsonStringToDate

lib/test/angular/1.7.0/angular.js:22252–22274  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

22250 var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
22251 // 1 2 3 4 5 6 7 8 9 10 11
22252 function jsonStringToDate(string) {
22253 var match;
22254 if ((match = string.match(R_ISO8601_STR))) {
22255 var date = new Date(0),
22256 tzHour = 0,
22257 tzMin = 0,
22258 dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,
22259 timeSetter = match[8] ? date.setUTCHours : date.setHours;
22260
22261 if (match[9]) {
22262 tzHour = toInt(match[9] + match[10]);
22263 tzMin = toInt(match[9] + match[11]);
22264 }
22265 dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
22266 var h = toInt(match[4] || 0) - tzHour;
22267 var m = toInt(match[5] || 0) - tzMin;
22268 var s = toInt(match[6] || 0);
22269 var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
22270 timeSetter.call(date, h, m, s, ms);
22271 return date;
22272 }
22273 return string;
22274 }
22275
22276
22277 return function(date, format, timezone) {

Callers 1

dateFilterFunction · 0.70

Calls 1

toIntFunction · 0.70

Tested by

no test coverage detected