MCPcopy
hub / github.com/flatpickr/flatpickr / setHours

Function setHours

src/index.ts:341–361  ·  view source on GitHub ↗

* Sets the hours, minutes, and optionally seconds * of the latest selected date object and the * corresponding time inputs * @param {Number} hours the hour. whether its military * or am-pm gets inferred from config * @param {Number} minutes the minutes * @param {Num

(hours: number, minutes: number, seconds: number)

Source from the content-addressed store, hash-verified

339 * @param {Number} seconds the seconds (optional)
340 */
341 function setHours(hours: number, minutes: number, seconds: number) {
342 if (self.latestSelectedDateObj !== undefined) {
343 self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
344 }
345
346 if (!self.hourElement || !self.minuteElement || self.isMobile) return;
347
348 self.hourElement.value = pad(
349 !self.config.time_24hr
350 ? ((12 + hours) % 12) + 12 * int(hours % 12 === 0)
351 : hours
352 );
353
354 self.minuteElement.value = pad(minutes);
355
356 if (self.amPM !== undefined)
357 self.amPM.textContent = self.l10n.amPM[int(hours >= 12)];
358
359 if (self.secondElement !== undefined)
360 self.secondElement.value = pad(seconds);
361 }
362
363 /**
364 * Handles the year input and incrementing events

Callers 3

setHoursFromInputsFunction · 0.85
setHoursFromDateFunction · 0.85
clearFunction · 0.85

Calls 2

padFunction · 0.90
intFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…