MCPcopy Create free account
hub / github.com/angular/components / generateOptions

Function generateOptions

src/material/timepicker/util.ts:85–107  ·  view source on GitHub ↗
(
  adapter: DateAdapter<D>,
  formats: MatDateFormats,
  min: D,
  max: D,
  interval: number,
)

Source from the content-addressed store, hash-verified

83 * @param interval Amount of seconds between each option.
84 */
85export 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. */
110export function validateAdapter(

Callers 2

_generateOptionsMethod · 0.90
util.spec.tsFile · 0.90

Calls 5

pushMethod · 0.65
maxMethod · 0.45
isValidMethod · 0.45
formatMethod · 0.45
addSecondsMethod · 0.45

Tested by

no test coverage detected