(string)
| 575 | var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/; |
| 576 | |
| 577 | function jsonStringToDate(string) { |
| 578 | var match; |
| 579 | if (match = string.match(R_ISO8061_STR)) { |
| 580 | var date = new Date(0), |
| 581 | tzHour = 0, |
| 582 | tzMin = 0; |
| 583 | if (match[9]) { |
| 584 | tzHour = int(match[9] + match[10]); |
| 585 | tzMin = int(match[9] + match[11]); |
| 586 | } |
| 587 | date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3])); |
| 588 | date.setUTCHours(int(match[4] || 0) - tzHour, |
| 589 | int(match[5] || 0) - tzMin, |
| 590 | int(match[6] || 0), |
| 591 | int(match[7] || 0)); |
| 592 | return date; |
| 593 | } |
| 594 | return string; |
| 595 | } |
| 596 | |
| 597 | function int(str) { |
| 598 | return parseInt(str, 10); |
no test coverage detected