mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 12:20:20 +01:00
22 lines
623 B
TypeScript
22 lines
623 B
TypeScript
import config from 'next.config';
|
|
import { useRouter } from 'next/router';
|
|
import { useTheme } from 'styled-components';
|
|
|
|
type LocaleTimeDate = {
|
|
date: string;
|
|
dateTime: string;
|
|
time: string;
|
|
};
|
|
|
|
const useLocaleDateTime = (now: Date): LocaleTimeDate => {
|
|
const { locale = config.i18n.defaultLocale } = useRouter() || {};
|
|
const { formats } = useTheme();
|
|
const date = new Intl.DateTimeFormat(locale, formats.date).format(now);
|
|
const time = new Intl.DateTimeFormat(locale, formats.time).format(now);
|
|
const dateTime = now.toISOString();
|
|
|
|
return { date, time, dateTime };
|
|
};
|
|
|
|
export default useLocaleDateTime;
|