mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 02:11:57 +00:00
Support null date for tsformat with timezone
This commit is contained in:
parent
9c712cca18
commit
bbc99b2164
|
@ -53,7 +53,10 @@ export function timestampmsOrNa(ts: number | Date | null): string {
|
||||||
* @param timezone timezone to use
|
* @param timezone timezone to use
|
||||||
* @returns formatted date in desired timezone (or globally configured timezone)
|
* @returns formatted date in desired timezone (or globally configured timezone)
|
||||||
*/
|
*/
|
||||||
export function timestampmsWithTimezone(ts: number | Date, timezone?: string): string {
|
export function timestampmsWithTimezone(ts: number | Date | null, timezone?: string): string {
|
||||||
|
if (!ts) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
return formatDate(toDate(ts), 'yyyy-MM-dd HH:mm:ss (z)', timezone);
|
return formatDate(toDate(ts), 'yyyy-MM-dd HH:mm:ss (z)', timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ describe('timeformatter.ts', () => {
|
||||||
expect(timestampmsWithTimezone(1651057500000)).toEqual('2022-04-27 11:05:00 (UTC)');
|
expect(timestampmsWithTimezone(1651057500000)).toEqual('2022-04-27 11:05:00 (UTC)');
|
||||||
setTimezone('UTC');
|
setTimezone('UTC');
|
||||||
expect(timestampmsWithTimezone(1651057500000)).toEqual('2022-04-27 11:05:00 (UTC)');
|
expect(timestampmsWithTimezone(1651057500000)).toEqual('2022-04-27 11:05:00 (UTC)');
|
||||||
|
expect(timestampmsWithTimezone(0)).toEqual('N/A');
|
||||||
|
expect(timestampmsWithTimezone(null)).toEqual('N/A');
|
||||||
});
|
});
|
||||||
it('timestampms convert correctly', () => {
|
it('timestampms convert correctly', () => {
|
||||||
setTimezone('UTC');
|
setTimezone('UTC');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user