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

Function jsonStringToDate

lib/test/angular/1.4.3/angular.js:18819–18841  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

18817 var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
18818 // 1 2 3 4 5 6 7 8 9 10 11
18819 function jsonStringToDate(string) {
18820 var match;
18821 if (match = string.match(R_ISO8601_STR)) {
18822 var date = new Date(0),
18823 tzHour = 0,
18824 tzMin = 0,
18825 dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,
18826 timeSetter = match[8] ? date.setUTCHours : date.setHours;
18827
18828 if (match[9]) {
18829 tzHour = toInt(match[9] + match[10]);
18830 tzMin = toInt(match[9] + match[11]);
18831 }
18832 dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
18833 var h = toInt(match[4] || 0) - tzHour;
18834 var m = toInt(match[5] || 0) - tzMin;
18835 var s = toInt(match[6] || 0);
18836 var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
18837 timeSetter.call(date, h, m, s, ms);
18838 return date;
18839 }
18840 return string;
18841 }
18842
18843
18844 return function(date, format, timezone) {

Callers 1

dateFilterFunction · 0.70

Calls 1

toIntFunction · 0.70

Tested by

no test coverage detected