(value?: any)
| 127 | const _YYYMMDD = /^([12]\d{3}-([1-9]|0[1-9]|1[0-2])-([1-9]|0[1-9]|[12]\d|3[01]))$/ |
| 128 | |
| 129 | function date (value?: any): Date | null { |
| 130 | if (value == null) return new Date() |
| 131 | |
| 132 | if (value instanceof Date) return value |
| 133 | |
| 134 | if (typeof value === 'string') { |
| 135 | let parsed |
| 136 | |
| 137 | if (_YYYMMDD.test(value)) { |
| 138 | return parseLocalDate(value) |
| 139 | } else { |
| 140 | parsed = Date.parse(value) |
| 141 | } |
| 142 | |
| 143 | if (!isNaN(parsed)) return new Date(parsed) |
| 144 | } |
| 145 | |
| 146 | return null |
| 147 | } |
| 148 | |
| 149 | const sundayJanuarySecond2000 = new Date(2000, 0, 2) |
| 150 |
no test coverage detected
searching dependent graphs…