MCPcopy Index your code
hub / github.com/flatpickr/flatpickr / buildTime

Function buildTime

src/index.ts:1132–1241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1130 }
1131
1132 function buildTime() {
1133 self.calendarContainer.classList.add("hasTime");
1134 if (self.config.noCalendar)
1135 self.calendarContainer.classList.add("noCalendar");
1136
1137 const defaults = getDefaultHours(self.config);
1138
1139 self.timeContainer = createElement<HTMLDivElement>("div", "flatpickr-time");
1140 self.timeContainer.tabIndex = -1;
1141 const separator = createElement("span", "flatpickr-time-separator", ":");
1142
1143 const hourInput = createNumberInput("flatpickr-hour", {
1144 "aria-label": self.l10n.hourAriaLabel,
1145 });
1146 self.hourElement = hourInput.getElementsByTagName(
1147 "input"
1148 )[0] as HTMLInputElement;
1149
1150 const minuteInput = createNumberInput("flatpickr-minute", {
1151 "aria-label": self.l10n.minuteAriaLabel,
1152 });
1153
1154 self.minuteElement = minuteInput.getElementsByTagName(
1155 "input"
1156 )[0] as HTMLInputElement;
1157
1158 self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
1159
1160 self.hourElement.value = pad(
1161 self.latestSelectedDateObj
1162 ? self.latestSelectedDateObj.getHours()
1163 : self.config.time_24hr
1164 ? defaults.hours
1165 : military2ampm(defaults.hours)
1166 );
1167
1168 self.minuteElement.value = pad(
1169 self.latestSelectedDateObj
1170 ? self.latestSelectedDateObj.getMinutes()
1171 : defaults.minutes
1172 );
1173
1174 self.hourElement.setAttribute("step", self.config.hourIncrement.toString());
1175 self.minuteElement.setAttribute(
1176 "step",
1177 self.config.minuteIncrement.toString()
1178 );
1179
1180 self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
1181 self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
1182 self.hourElement.setAttribute("maxlength", "2");
1183
1184 self.minuteElement.setAttribute("min", "0");
1185 self.minuteElement.setAttribute("max", "59");
1186 self.minuteElement.setAttribute("maxlength", "2");
1187
1188 self.timeContainer.appendChild(hourInput);
1189 self.timeContainer.appendChild(separator);

Callers 1

buildFunction · 0.85

Calls 6

getDefaultHoursFunction · 0.90
createElementFunction · 0.90
createNumberInputFunction · 0.90
padFunction · 0.90
intFunction · 0.90
military2ampmFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…