mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-22 11:05:17 +00:00
Adapt to date-fns-tz 3.0 changes
This commit is contained in:
parent
c7e32720bf
commit
dbccd30ec6
|
@ -1,12 +1,12 @@
|
||||||
import { parse, toDate } from 'date-fns';
|
import { parse, toDate } from 'date-fns';
|
||||||
import { format, utcToZonedTime, zonedTimeToUtc } from 'date-fns-tz';
|
import { format, toZonedTime, fromZonedTime } from 'date-fns-tz';
|
||||||
import humanizeDuration from 'humanize-duration';
|
import humanizeDuration from 'humanize-duration';
|
||||||
import { isNotUndefined } from './numberformat';
|
import { isNotUndefined } from './numberformat';
|
||||||
|
|
||||||
/** Parse date from string, returns date in UTC! */
|
/** Parse date from string, returns date in UTC! */
|
||||||
export function dateFromString(datestring: string, format: string): Date {
|
export function dateFromString(datestring: string, format: string): Date {
|
||||||
const localTime = parse(datestring, format, 0);
|
const localTime = parse(datestring, format, 0);
|
||||||
return zonedTimeToUtc(localTime, 'UTC');
|
return fromZonedTime(localTime, 'UTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
let locTimeZone = 'UTC';
|
let locTimeZone = 'UTC';
|
||||||
|
@ -25,7 +25,7 @@ function getTimeZone(tz?: string): string {
|
||||||
|
|
||||||
function formatDate(date: Date, formatPattern: string, timezone?: string): string {
|
function formatDate(date: Date, formatPattern: string, timezone?: string): string {
|
||||||
const timezoneRes = getTimeZone(timezone);
|
const timezoneRes = getTimeZone(timezone);
|
||||||
return format(utcToZonedTime(date, timezoneRes), formatPattern, {
|
return format(toZonedTime(date, timezoneRes), formatPattern, {
|
||||||
timeZone: timezoneRes,
|
timeZone: timezoneRes,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user