(string)
| 22971 | var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; |
| 22972 | // 1 2 3 4 5 6 7 8 9 10 11 |
| 22973 | function jsonStringToDate(string) { |
| 22974 | var match; |
| 22975 | if ((match = string.match(R_ISO8601_STR))) { |
| 22976 | var date = new Date(0), |
| 22977 | tzHour = 0, |
| 22978 | tzMin = 0, |
| 22979 | dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear, |
| 22980 | timeSetter = match[8] ? date.setUTCHours : date.setHours; |
| 22981 | |
| 22982 | if (match[9]) { |
| 22983 | tzHour = toInt(match[9] + match[10]); |
| 22984 | tzMin = toInt(match[9] + match[11]); |
| 22985 | } |
| 22986 | dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3])); |
| 22987 | var h = toInt(match[4] || 0) - tzHour; |
| 22988 | var m = toInt(match[5] || 0) - tzMin; |
| 22989 | var s = toInt(match[6] || 0); |
| 22990 | var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000); |
| 22991 | timeSetter.call(date, h, m, s, ms); |
| 22992 | return date; |
| 22993 | } |
| 22994 | return string; |
| 22995 | } |
| 22996 | |
| 22997 | |
| 22998 | return function(date, format, timezone) { |
no test coverage detected