Mnovich/temporal foreground tasks (#2895)

Co-authored-by: Carlos M. Lopez <carlopez@squareup.com>
This commit is contained in:
Max Novich
2025-06-20 16:19:58 -07:00
committed by GitHub
parent b3aed4bc11
commit 180b1df25d
58 changed files with 4009 additions and 1920 deletions
+41
View File
@@ -0,0 +1,41 @@
export const formatToLocalDateTime = (dateString?: string | null): string => {
if (!dateString) {
return 'N/A';
}
try {
const date = new Date(dateString);
// Check if the date is valid
if (isNaN(date.getTime())) {
return 'Invalid Date';
}
return date.toLocaleString(); // Uses user's locale and timezone
} catch (e) {
console.error('Error formatting date:', e);
return 'Invalid Date';
}
};
export const formatToLocalDateWithTimezone = (dateString?: string | null): string => {
if (!dateString) {
return 'N/A';
}
try {
const date = new Date(dateString);
if (isNaN(date.getTime())) {
return 'Invalid Date';
}
// Format: Jan 1, 2023, 10:00:00 AM PST (example)
return date.toLocaleString(undefined, {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: '2-digit',
second: '2-digit',
timeZoneName: 'short',
});
} catch (e) {
console.error('Error formatting date with timezone:', e);
return 'Invalid Date';
}
};