import { LOCALE } from "@config"; interface DatetimesProps { pubDatetime: string | Date; modDatetime: string | Date | undefined | null; } interface Props extends DatetimesProps { size?: "sm" | "lg"; className?: string; } export default function Datetime({ pubDatetime, modDatetime, size = "sm", className, }: Props) { return (
{modDatetime && modDatetime > pubDatetime ? ( Updated: ) : ( Published: )}
); } const FormattedDatetime = ({ pubDatetime, modDatetime }: DatetimesProps) => { const myDatetime = new Date( modDatetime && modDatetime > pubDatetime ? modDatetime : pubDatetime ); const date = myDatetime.toLocaleDateString(LOCALE.langTag, { year: "numeric", month: "short", day: "numeric", }); const time = myDatetime.toLocaleTimeString(LOCALE.langTag, { hour: "2-digit", minute: "2-digit", }); return ( <>  at  {time} ); };