This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add client-side date formatting and fix page build issues
- Loading branch information
Showing
11 changed files
with
83 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use client" | ||
|
||
import { useEffect, useState } from "react" | ||
import locale from "date-fns/locale/en-US" | ||
import { formatInTimeZone } from "date-fns-tz" | ||
import { format } from "date-fns" | ||
|
||
export type FormattedDateProps = { | ||
date: Date | ||
format: string | ||
} | ||
|
||
const defaultTimezone = "America/New_York" | ||
|
||
export function FormattedDate({ date, format: formatStr }: FormattedDateProps) { | ||
const [value, setValue] = useState(formatInTimeZone(date, defaultTimezone, formatStr, { | ||
locale, | ||
})) | ||
|
||
useEffect(() => { | ||
setValue(format(date, formatStr)) | ||
}, [date, formatStr]) | ||
|
||
return value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use client" | ||
|
||
import { useEffect, useState } from "react"; | ||
|
||
export function TimezoneNotice() { | ||
const [isUsingLocalTimezone, setUsingLocalTimezone] = useState(false) | ||
useEffect(() => { | ||
setUsingLocalTimezone(true) | ||
}, []) | ||
|
||
if (isUsingLocalTimezone) return "Dates and times are displayed in your local time zone." | ||
return "Dates and times are displayed in EST." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters