(date: Date, timeFormat: "12" | "24" = "24")
| 947 | * @returns Formatted date and time string |
| 948 | */ |
| 949 | export function formatDateTime(date: Date, timeFormat: "12" | "24" = "24"): string { |
| 950 | if (!isValid(date)) { |
| 951 | tasknotesLogger.warn("Invalid date provided to formatDateTime:", { |
| 952 | category: "validation", |
| 953 | operation: "invalid-date-provided-formatdatetime", |
| 954 | details: { value: date }, |
| 955 | }); |
| 956 | return ""; |
| 957 | } |
| 958 | |
| 959 | return format(date, timeFormat === "12" ? "MMM d, yyyy h:mm a" : "MMM d, yyyy HH:mm"); |
| 960 | } |
| 961 | |
| 962 | /** |
| 963 | * Format a date string with time in the user's preferred format |
no test coverage detected