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

Function jsonStringToDate

test/angular/1.2/angular-mocks.js:564–582  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

562var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
563
564function jsonStringToDate(string) {
565 var match;
566 if (match = string.match(R_ISO8061_STR)) {
567 var date = new Date(0),
568 tzHour = 0,
569 tzMin = 0;
570 if (match[9]) {
571 tzHour = int(match[9] + match[10]);
572 tzMin = int(match[9] + match[11]);
573 }
574 date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
575 date.setUTCHours(int(match[4]||0) - tzHour,
576 int(match[5]||0) - tzMin,
577 int(match[6]||0),
578 int(match[7]||0));
579 return date;
580 }
581 return string;
582}
583
584function int(str) {
585 return parseInt(str, 10);

Callers 1

angular-mocks.jsFile · 0.70

Calls 2

matchMethod · 0.80
intFunction · 0.70

Tested by

no test coverage detected