MCPcopy Create free account
hub / github.com/apache/cloudstack / jsonStringToDate

Function jsonStringToDate

tools/ngui/static/js/lib/angular.js:10121–10136  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

10119
10120 var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
10121 function jsonStringToDate(string){
10122 var match;
10123 if (match = string.match(R_ISO8601_STR)) {
10124 var date = new Date(0),
10125 tzHour = 0,
10126 tzMin = 0;
10127 if (match[9]) {
10128 tzHour = int(match[9] + match[10]);
10129 tzMin = int(match[9] + match[11]);
10130 }
10131 date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
10132 date.setUTCHours(int(match[4]||0) - tzHour, int(match[5]||0) - tzMin, int(match[6]||0), int(match[7]||0));
10133 return date;
10134 }
10135 return string;
10136 }
10137
10138
10139 return function(date, format) {

Callers 1

dateFilterFunction · 0.85

Calls 2

intFunction · 0.85
matchMethod · 0.45

Tested by

no test coverage detected