This commit is contained in:
Carl-Gerhard Lindesvärd
2024-07-24 00:41:53 +02:00
parent 8025859b6d
commit 2613a88c63
2 changed files with 36 additions and 19 deletions

View File

@@ -110,8 +110,11 @@ export async function chQuery<T extends Record<string, any>>(
return (await chQueryWithMeta<T>(query)).data;
}
export function formatClickhouseDate(_date: Date | string) {
export function formatClickhouseDate(_date: Date | string, skipTime = false) {
const date = typeof _date === 'string' ? new Date(_date) : _date;
if (skipTime) {
return date.toISOString().split('T')[0];
}
return date.toISOString().replace('T', ' ').replace(/Z+$/, '');
}