Files
starface-outlook-sync-addin/node_modules/@fluentui/date-time-utilities/lib/timeFormatting/index.js
T
Stefan Hacker 37ad745546 first commit
2026-04-03 09:38:48 +02:00

19 lines
718 B
JavaScript

/**
* 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
*/
export 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;
};
//# sourceMappingURL=index.js.map