(string)
| 21197 | var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; |
| 21198 | // 1 2 3 4 5 6 7 8 9 10 11 |
| 21199 | function jsonStringToDate(string) { |
| 21200 | var match; |
| 21201 | if ((match = string.match(R_ISO8601_STR))) { |
| 21202 | var date = new Date(0), |
| 21203 | tzHour = 0, |
| 21204 | tzMin = 0, |
| 21205 | dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear, |
| 21206 | timeSetter = match[8] ? date.setUTCHours : date.setHours; |
| 21207 | |
| 21208 | if (match[9]) { |
| 21209 | tzHour = toInt(match[9] + match[10]); |
| 21210 | tzMin = toInt(match[9] + match[11]); |
| 21211 | } |
| 21212 | dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3])); |
| 21213 | var h = toInt(match[4] || 0) - tzHour; |
| 21214 | var m = toInt(match[5] || 0) - tzMin; |
| 21215 | var s = toInt(match[6] || 0); |
| 21216 | var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000); |
| 21217 | timeSetter.call(date, h, m, s, ms); |
| 21218 | return date; |
| 21219 | } |
| 21220 | return string; |
| 21221 | } |
| 21222 | |
| 21223 | |
| 21224 | return function(date, format, timezone) { |
no test coverage detected