//#region src/components/pisellDateTimeDisplay/utils/formatTime.ts
/**
* 格式化时间
* @param time dayjs 时间对象
* @param config 时间格式配置
* @returns 格式化后的时间字符串
*
* @example
* formatTime(dayjs(), { use12Hour: false, showSeconds: false, padHour: false })
* // => "13:45"
*
* formatTime(dayjs(), { use12Hour: true, showSeconds: false, padHour: true })
* // => "01:45 PM"
*
* formatTime(dayjs(), { use12Hour: false, showSeconds: true, padHour: false })
* // => "13:45:30"
*/
function formatTime(time, config) {
	const { use12Hour = false, showSeconds = false, padHour = false, onlyShowHour = false } = config || {};
	if (onlyShowHour) return padHour ? time.format("HH") : time.format("H");
	if (use12Hour) {
		const hourFormat = padHour ? "hh" : "h";
		const timeFormat = showSeconds ? `${hourFormat}:mm:ss A` : `${hourFormat}:mm A`;
		return time.format(timeFormat);
	}
	const hourFormat = padHour ? "HH" : "H";
	const timeFormat = showSeconds ? `${hourFormat}:mm:ss` : `${hourFormat}:mm`;
	return time.format(timeFormat);
}
//#endregion
exports.formatTime = formatTime;
