(dateString: string, timeFormat: "12" | "24" = "24")
| 966 | * @returns Formatted time string, or original if no time component |
| 967 | */ |
| 968 | export function formatDateStringTime(dateString: string, timeFormat: "12" | "24" = "24"): string { |
| 969 | if (!dateString || !hasTimeComponent(dateString)) { |
| 970 | return dateString; |
| 971 | } |
| 972 | |
| 973 | try { |
| 974 | const parsed = parseDateToLocal(dateString); |
| 975 | return formatTime(parsed, timeFormat); |
| 976 | } catch (error) { |
| 977 | tasknotesLogger.error("Error formatting date string time:", { |
| 978 | category: "validation", |
| 979 | operation: "formatting-date-string-time", |
| 980 | details: { dateString }, |
| 981 | error: error, |
| 982 | }); |
| 983 | return dateString; |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | /** |
| 988 | * Helper function to create formatDateTimeForDisplay calls with user's time format preference |
no test coverage detected