revert context on __root beforeLoad refactor project structure refactor role badge dynamic nav menu
21 lines
583 B
TypeScript
21 lines
583 B
TypeScript
import { getLocale } from '@/paraglide/runtime';
|
|
|
|
const locale = getLocale() === 'vi' ? 'vi-VN' : 'en-US';
|
|
|
|
export const formatters = {
|
|
dateTime: (v: string | Date) => {
|
|
const parts = new Intl.DateTimeFormat(locale, {
|
|
day: '2-digit',
|
|
month: '2-digit',
|
|
year: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
hour12: true,
|
|
}).formatToParts(new Date(v));
|
|
|
|
const map = Object.fromEntries(parts.map((p) => [p.type, p.value]));
|
|
|
|
return `${map.day}/${map.month}/${map.year} ${map.hour}:${map.minute} ${map.hour12 ? 'AM' : 'PM'}`;
|
|
},
|
|
};
|