fix: update day picker to handle utc display

This commit is contained in:
Scott Wilson
2025-07-17 20:16:57 -07:00
parent bfda3776ee
commit 277b92ddec
6 changed files with 71 additions and 29 deletions
+24
View File
@@ -0,0 +1,24 @@
import { format } from "date-fns";
export enum Timezone {
Local = "local",
UTC = "UTC"
}
export const formatDateTime = ({
timezone,
timestamp,
dateFormat = "MMM do yyyy, hh:mm a"
}: {
timestamp: string | Date;
timezone?: Timezone;
dateFormat?: string;
}) => {
const date = new Date(timestamp);
if (timezone === Timezone.UTC) {
const utcDate = new Date(date.getTime() + date.getTimezoneOffset() * 60000);
return `${format(utcDate, dateFormat)} UTC`;
}
return format(date, dateFormat);
};