diff --git a/src/utils/dayjs.ts b/src/utils/dayjs.ts index f830581..459b5c1 100644 --- a/src/utils/dayjs.ts +++ b/src/utils/dayjs.ts @@ -8,12 +8,12 @@ dayjs.extend(timezone); dayjs.extend(customParseFormat); // interpret all date strings as Pacific time, in case this gets built in some -// other time zone +// other time zone. make sure to call the .tz() method instead of just dayjs(). dayjs.tz.setDefault("America/Los_Angeles"); export default dayjs; -export const parseYMD = (date: string) => dayjs(date, "YYYY-MM-DD", true); +export const parseYMD = (date: string) => dayjs.tz(date); export const parseYMDToDate = (date: string) => parseYMD(date).toDate(); -export const formatShortMDY = (date: Date) => date ? dayjs(date).format("MMM D, YYYY") : ""; -export const formatRSSDate = (date: Date) => date ? dayjs(date).format("ddd, D MMM YYYY HH:mm:ss ZZ") : ""; +export const formatShortMDY = (date: Date) => date ? dayjs.tz(date).format("MMM D, YYYY") : ""; +export const formatRSSDate = (date: Date) => date ? dayjs.tz(date).format("ddd, D MMM YYYY HH:mm:ss ZZ") : "";