Files
T
Stefan Hacker 37ad745546 first commit
2026-04-03 09:38:48 +02:00

25 lines
1021 B
JavaScript

define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatTimeString = void 0;
/**
* Format a date object to a localized time string using the browser's default locale
* @param date - Input date to format
* @param showSeconds - Whether to show seconds in the formatted string
* @param useHour12 - Whether to use 12-hour time
*/
var formatTimeString = function (date, showSeconds, useHour12) {
var localeTimeString = date.toLocaleTimeString([], {
hour: 'numeric',
minute: '2-digit',
second: showSeconds ? '2-digit' : undefined,
hour12: useHour12,
});
if (!useHour12 && localeTimeString.slice(0, 2) === '24') {
localeTimeString = '00' + localeTimeString.slice(2);
}
return localeTimeString;
};
exports.formatTimeString = formatTimeString;
});
//# sourceMappingURL=index.js.map