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

Function jsonStringToDate

lib/test/angular/1.6.7/angular.js:21814–21836  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

21812 var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
21813 // 1 2 3 4 5 6 7 8 9 10 11
21814 function jsonStringToDate(string) {
21815 var match;
21816 if ((match = string.match(R_ISO8601_STR))) {
21817 var date = new Date(0),
21818 tzHour = 0,
21819 tzMin = 0,
21820 dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,
21821 timeSetter = match[8] ? date.setUTCHours : date.setHours;
21822
21823 if (match[9]) {
21824 tzHour = toInt(match[9] + match[10]);
21825 tzMin = toInt(match[9] + match[11]);
21826 }
21827 dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
21828 var h = toInt(match[4] || 0) - tzHour;
21829 var m = toInt(match[5] || 0) - tzMin;
21830 var s = toInt(match[6] || 0);
21831 var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
21832 timeSetter.call(date, h, m, s, ms);
21833 return date;
21834 }
21835 return string;
21836 }
21837
21838
21839 return function(date, format, timezone) {

Callers 1

dateFilterFunction · 0.70

Calls 1

toIntFunction · 0.70

Tested by

no test coverage detected