mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 11:36:05 +00:00
fix(settings): format the date format files prettier flagged
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import { DEFAULT_DATE_FORMAT, type DateFormat } from '@trek/shared'
|
||||
import { useCallback } from 'react'
|
||||
import { useTranslation } from '../i18n'
|
||||
import { useSettingsStore } from '../store/settingsStore'
|
||||
import { formatDisplayDate, formatDisplayDateTime } from '../utils/dateFormat'
|
||||
import { DEFAULT_DATE_FORMAT, type DateFormat } from '@trek/shared';
|
||||
import { useCallback } from 'react';
|
||||
import { useTranslation } from '../i18n';
|
||||
import { useSettingsStore } from '../store/settingsStore';
|
||||
import { formatDisplayDate, formatDisplayDateTime } from '../utils/dateFormat';
|
||||
|
||||
/** The current user's date format (#2971); 'auto' follows the interface language. */
|
||||
export function useDateFormat(): DateFormat {
|
||||
return useSettingsStore((s) => s.settings.date_format) ?? DEFAULT_DATE_FORMAT
|
||||
return useSettingsStore((s) => s.settings.date_format) ?? DEFAULT_DATE_FORMAT;
|
||||
}
|
||||
|
||||
/** The same value outside React (stores, exports, plain helpers), read when called. */
|
||||
export function readDateFormat(): DateFormat {
|
||||
return useSettingsStore.getState().settings.date_format ?? DEFAULT_DATE_FORMAT
|
||||
return useSettingsStore.getState().settings.date_format ?? DEFAULT_DATE_FORMAT;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -19,15 +19,15 @@ export function readDateFormat(): DateFormat {
|
||||
* the user's date format, for components that write dates.
|
||||
*/
|
||||
export function useFormatDate() {
|
||||
const { locale } = useTranslation()
|
||||
const format = useDateFormat()
|
||||
const { locale } = useTranslation();
|
||||
const format = useDateFormat();
|
||||
const date = useCallback(
|
||||
(value: Date, opts?: Intl.DateTimeFormatOptions) => formatDisplayDate(value, locale, opts, format),
|
||||
[locale, format]
|
||||
)
|
||||
);
|
||||
const dateTime = useCallback(
|
||||
(value: Date, opts?: Intl.DateTimeFormatOptions) => formatDisplayDateTime(value, locale, opts, format),
|
||||
[locale, format]
|
||||
)
|
||||
return { formatDate: date, formatDateTime: dateTime, locale, dateFormat: format }
|
||||
);
|
||||
return { formatDate: date, formatDateTime: dateTime, locale, dateFormat: format };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user