MCPcopy
hub / github.com/flatpickr/flatpickr / updateTime

Function updateTime

src/index.ts:178–211  ·  view source on GitHub ↗

* The handler for all events targeting the time inputs

(
    e?: MouseEvent | IncrementEvent | KeyboardEvent | FocusEvent
  )

Source from the content-addressed store, hash-verified

176 * The handler for all events targeting the time inputs
177 */
178 function updateTime(
179 e?: MouseEvent | IncrementEvent | KeyboardEvent | FocusEvent
180 ) {
181 if (self.selectedDates.length === 0) {
182 const defaultDate =
183 self.config.minDate === undefined ||
184 compareDates(new Date(), self.config.minDate) >= 0
185 ? new Date()
186 : new Date(self.config.minDate.getTime());
187
188 const defaults = getDefaultHours(self.config);
189 defaultDate.setHours(
190 defaults.hours,
191 defaults.minutes,
192 defaults.seconds,
193 defaultDate.getMilliseconds()
194 );
195
196 self.selectedDates = [defaultDate];
197 self.latestSelectedDateObj = defaultDate;
198 }
199 if (e !== undefined && e.type !== "blur") {
200 timeWrapper(e);
201 }
202
203 const prevValue = self._input.value;
204
205 setHoursFromInputs();
206 updateValue();
207
208 if (self._input.value !== prevValue) {
209 self._debouncedChange();
210 }
211 }
212
213 function ampm2military(hour: number, amPM: string) {
214 return (hour % 12) + 12 * int(amPM === self.l10n.amPM[1]);

Callers 3

bindEventsFunction · 0.85
documentClickFunction · 0.85
onKeyDownFunction · 0.85

Calls 5

compareDatesFunction · 0.90
getDefaultHoursFunction · 0.90
timeWrapperFunction · 0.85
setHoursFromInputsFunction · 0.85
updateValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…