MCPcopy
hub / github.com/callumalpass/tasknotes / formatDateStringTime

Function formatDateStringTime

src/utils/dateUtils.ts:968–985  ·  view source on GitHub ↗
(dateString: string, timeFormat: "12" | "24" = "24")

Source from the content-addressed store, hash-verified

966 * @returns Formatted time string, or original if no time component
967 */
968export 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

Callers 1

createTimeFormatHelperFunction · 0.85

Calls 4

hasTimeComponentFunction · 0.85
parseDateToLocalFunction · 0.85
errorMethod · 0.80
formatTimeFunction · 0.70

Tested by

no test coverage detected