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

Function jsonStringToDate

test/angular/1.3/angular.js:17435–17457  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

17433 var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
17434 // 1 2 3 4 5 6 7 8 9 10 11
17435 function jsonStringToDate(string) {
17436 var match;
17437 if (match = string.match(R_ISO8601_STR)) {
17438 var date = new Date(0),
17439 tzHour = 0,
17440 tzMin = 0,
17441 dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,
17442 timeSetter = match[8] ? date.setUTCHours : date.setHours;
17443
17444 if (match[9]) {
17445 tzHour = int(match[9] + match[10]);
17446 tzMin = int(match[9] + match[11]);
17447 }
17448 dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3]));
17449 var h = int(match[4] || 0) - tzHour;
17450 var m = int(match[5] || 0) - tzMin;
17451 var s = int(match[6] || 0);
17452 var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
17453 timeSetter.call(date, h, m, s, ms);
17454 return date;
17455 }
17456 return string;
17457 }
17458
17459
17460 return function(date, format, timezone) {

Callers 1

dateFilterFunction · 0.70

Calls 2

matchMethod · 0.80
intFunction · 0.70

Tested by

no test coverage detected