(string)
| 15414 | var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; |
| 15415 | // 1 2 3 4 5 6 7 8 9 10 11 |
| 15416 | function jsonStringToDate(string) { |
| 15417 | var match; |
| 15418 | if (match = string.match(R_ISO8601_STR)) { |
| 15419 | var date = new Date(0), |
| 15420 | tzHour = 0, |
| 15421 | tzMin = 0, |
| 15422 | dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear, |
| 15423 | timeSetter = match[8] ? date.setUTCHours : date.setHours; |
| 15424 | |
| 15425 | if (match[9]) { |
| 15426 | tzHour = int(match[9] + match[10]); |
| 15427 | tzMin = int(match[9] + match[11]); |
| 15428 | } |
| 15429 | dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3])); |
| 15430 | var h = int(match[4]||0) - tzHour; |
| 15431 | var m = int(match[5]||0) - tzMin; |
| 15432 | var s = int(match[6]||0); |
| 15433 | var ms = Math.round(parseFloat('0.' + (match[7]||0)) * 1000); |
| 15434 | timeSetter.call(date, h, m, s, ms); |
| 15435 | return date; |
| 15436 | } |
| 15437 | return string; |
| 15438 | } |
| 15439 | |
| 15440 | |
| 15441 | return function(date, format) { |
no test coverage detected