mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 05:07:15 +01:00
Fixed timezone date format.
This commit is contained in:
parent
17e2658fdc
commit
511fec2ddb
6 changed files with 22 additions and 20 deletions
|
|
@ -13,13 +13,15 @@ export function useTimezone() {
|
|||
setTimezone(value);
|
||||
};
|
||||
|
||||
const formatDate = (date: string, pattern: string) => {
|
||||
return formatInTimeZone(
|
||||
/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$/.test(date)
|
||||
? date
|
||||
: date.split(' ').join('T') + 'Z',
|
||||
timezone,
|
||||
pattern,
|
||||
const formatTimezoneDate = (date: string, pattern: string) => {
|
||||
return (
|
||||
formatInTimeZone(
|
||||
/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]{3})?Z$/.test(date)
|
||||
? date
|
||||
: date.split(' ').join('T') + 'Z',
|
||||
timezone,
|
||||
pattern,
|
||||
) + `, ${date}, ${pattern}, ${timezone}, ${formatInTimeZone(date, timezone, pattern)}`
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -31,7 +33,7 @@ export function useTimezone() {
|
|||
return utcToZonedTime(date, timezone);
|
||||
};
|
||||
|
||||
return { timezone, saveTimezone, formatDate, toUtc, fromUtc };
|
||||
return { timezone, saveTimezone, formatTimezoneDate, toUtc, fromUtc };
|
||||
}
|
||||
|
||||
export default useTimezone;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue