( adapter: DateAdapter<D>, formats: MatDateFormats, min: D, max: D, interval: number, )
| 83 | * @param interval Amount of seconds between each option. |
| 84 | */ |
| 85 | export function generateOptions<D>( |
| 86 | adapter: DateAdapter<D>, |
| 87 | formats: MatDateFormats, |
| 88 | min: D, |
| 89 | max: D, |
| 90 | interval: number, |
| 91 | ): MatTimepickerOption<D>[] { |
| 92 | // Avoid generating intervals less than a second, because it can freeze up the browser. |
| 93 | interval = Math.max(interval, 1); |
| 94 | const options: MatTimepickerOption<D>[] = []; |
| 95 | let current = adapter.compareTime(min, max) < 1 ? min : max; |
| 96 | |
| 97 | while ( |
| 98 | adapter.sameDate(current, min) && |
| 99 | adapter.compareTime(current, max) < 1 && |
| 100 | adapter.isValid(current) |
| 101 | ) { |
| 102 | options.push({value: current, label: adapter.format(current, formats.display.timeOptionLabel)}); |
| 103 | current = adapter.addSeconds(current, interval); |
| 104 | } |
| 105 | |
| 106 | return options; |
| 107 | } |
| 108 | |
| 109 | /** Checks whether a date adapter is set up correctly for use with the timepicker. */ |
| 110 | export function validateAdapter( |
no test coverage detected