mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-30 14:38:57 +02:00
Use locale to format dates and times (#123)
* Use deployment url in demo description. Close #131
This commit is contained in:
parent
8263926168
commit
8aec24308e
40 changed files with 1240 additions and 864 deletions
|
@ -7,13 +7,14 @@ import { useMutation } from "react-query";
|
|||
import Button from "../button";
|
||||
import { usePoll } from "../poll-context";
|
||||
import Popover from "../popover";
|
||||
import { usePreferences } from "../preferences/use-preferences";
|
||||
|
||||
export interface PollSubheaderProps {}
|
||||
|
||||
const PollSubheader: React.VoidFunctionComponent<PollSubheaderProps> = () => {
|
||||
const { poll } = usePoll();
|
||||
const { t } = useTranslation("app");
|
||||
|
||||
const { locale } = usePreferences();
|
||||
const {
|
||||
mutate: sendVerificationEmail,
|
||||
isLoading: isSendingVerificationEmail,
|
||||
|
@ -29,14 +30,6 @@ const PollSubheader: React.VoidFunctionComponent<PollSubheaderProps> = () => {
|
|||
t={t}
|
||||
values={{
|
||||
name: poll.authorName,
|
||||
date: Date.parse(poll.createdAt),
|
||||
formatParams: {
|
||||
date: {
|
||||
year: "numeric",
|
||||
month: "numeric",
|
||||
day: "numeric",
|
||||
},
|
||||
},
|
||||
}}
|
||||
components={{
|
||||
b: <span className="font-medium text-indigo-500" />,
|
||||
|
@ -88,7 +81,9 @@ const PollSubheader: React.VoidFunctionComponent<PollSubheaderProps> = () => {
|
|||
</div>
|
||||
<span className="hidden md:inline"> • </span>
|
||||
<span className="whitespace-nowrap">
|
||||
{formatRelative(new Date(poll.createdAt), new Date())}
|
||||
{formatRelative(new Date(poll.createdAt), new Date(), {
|
||||
locale,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue