(dateString: string)
| 903 | * Extract just the time part from a datetime string, returns null if no time |
| 904 | */ |
| 905 | export function getTimePart(dateString: string): string | null { |
| 906 | if (!dateString || !hasTimeComponent(dateString)) { |
| 907 | return null; |
| 908 | } |
| 909 | |
| 910 | try { |
| 911 | const parsed = parseDateToLocalInternal(dateString); |
| 912 | return format(parsed, "HH:mm"); |
| 913 | } catch (error) { |
| 914 | tasknotesLogger.error("Error extracting time part:", { |
| 915 | category: "validation", |
| 916 | operation: "extracting-time-part", |
| 917 | details: { dateString }, |
| 918 | error: error, |
| 919 | }); |
| 920 | return null; |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | /** |
| 925 | * Format a Date object with time in the user's preferred format (12h or 24h) |
no test coverage detected