UNPKG

@mantine/dates

Version:

Calendars, date and time pickers based on Mantine components

18 lines (17 loc) 1.3 kB
"use client"; const require_pad_time = require("../../TimePicker/utils/pad-time/pad-time.cjs"); const require_split_time_string = require("../../TimePicker/utils/split-time-string/split-time-string.cjs"); //#region packages/@mantine/dates/src/components/TimeValue/get-formatted-time/get-formatted-time.ts function getTimeFromDate(date, withSeconds) { return `${date.getHours()}:${date.getMinutes()}${withSeconds ? `:${date.getSeconds()}` : ""}`; } function getFormattedTime({ value, format, amPmLabels, withSeconds }) { const splitted = require_split_time_string.splitTimeString(typeof value === "string" ? value : getTimeFromDate(value, withSeconds)); if (splitted.hours === null || splitted.minutes === null) return null; if (format === "24h") return `${require_pad_time.padTime(splitted.hours)}:${require_pad_time.padTime(splitted.minutes)}${withSeconds ? `:${require_pad_time.padTime(splitted.seconds || 0)}` : ""}`; const isPm = splitted.hours >= 12; return `${splitted.hours % 12 === 0 ? 12 : splitted.hours % 12}:${require_pad_time.padTime(splitted.minutes)}${withSeconds ? `:${require_pad_time.padTime(splitted.seconds || 0)}` : ""} ${isPm ? amPmLabels.pm : amPmLabels.am}`; } //#endregion exports.getFormattedTime = getFormattedTime; //# sourceMappingURL=get-formatted-time.cjs.map