(min: string, todayParts: DatetimeParts)
| 201 | * month, day, hour, and minute information. |
| 202 | */ |
| 203 | export const parseMinParts = (min: string, todayParts: DatetimeParts): DatetimeParts | undefined => { |
| 204 | const result = parseDate(min); |
| 205 | |
| 206 | /** |
| 207 | * If min was not a valid date then return undefined. |
| 208 | */ |
| 209 | if (result === undefined) { |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | const { month, day, year, hour, minute } = result; |
| 214 | |
| 215 | /** |
| 216 | * When passing in `max` or `min`, developers |
| 217 | * can pass in any ISO-8601 string. This means |
| 218 | * that not all of the date/time fields are defined. |
| 219 | * For example, passing max="2012" is valid even though |
| 220 | * there is no month, day, hour, or minute data. |
| 221 | * However, all of this data is required when clamping the date |
| 222 | * so that the correct initial value can be selected. As a result, |
| 223 | * we need to fill in any omitted data with the min or max values. |
| 224 | */ |
| 225 | return { |
| 226 | month: month ?? 1, |
| 227 | day: day ?? 1, |
| 228 | /** |
| 229 | * Passing in "HH:mm" is a valid ISO-8601 |
| 230 | * string, so we just default to the current year |
| 231 | * in this case. |
| 232 | */ |
| 233 | year: year ?? todayParts.year, |
| 234 | hour: hour ?? 0, |
| 235 | minute: minute ?? 0, |
| 236 | }; |
| 237 | }; |
no test coverage detected