mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
feat: add locale configuration for Datetime component (#59)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { LOCALE } from "@config";
|
||||
|
||||
export interface Props {
|
||||
datetime: string | Date;
|
||||
size?: "sm" | "lg";
|
||||
@@ -28,13 +30,13 @@ export default function Datetime({ datetime, size = "sm", className }: Props) {
|
||||
const FormattedDatetime = ({ datetime }: { datetime: string | Date }) => {
|
||||
const myDatetime = new Date(datetime);
|
||||
|
||||
const date = myDatetime.toLocaleDateString([], {
|
||||
const date = myDatetime.toLocaleDateString(LOCALE, {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
|
||||
const time = myDatetime.toLocaleTimeString([], {
|
||||
const time = myDatetime.toLocaleTimeString(LOCALE, {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user