fix chart and timezone issues, pass consistent dates to DB.
Closes #3700
This commit is contained in:
1 parent
81bedec6d5
commit
6751bf88bb
10 files changed
+157
-79
No files matched your search
+10
-2
@@ -27,6 +27,14 @@ const DATE_FORMATS = {
|
||||
year: 'YYYY-01-01 HH24:00:00',
|
||||
};
|
||||
|
||||
const DATE_FORMATS_UTC = {
|
||||
minute: 'YYYY-MM-DD"T"HH24:MI:00"Z"',
|
||||
hour: 'YYYY-MM-DD"T"HH24:00:00"Z"',
|
||||
day: 'YYYY-MM-DD"T"HH24:00:00"Z"',
|
||||
month: 'YYYY-MM-01"T"HH24:00:00"Z"',
|
||||
year: 'YYYY-01-01"T"HH24:00:00"Z"',
|
||||
};
|
||||
|
||||
function getAddIntervalQuery(field: string, interval: string): string {
|
||||
return `${field} + interval '${interval}'`;
|
||||
}
|
||||
@@ -40,11 +48,11 @@ function getCastColumnQuery(field: string, type: string): string {
|
||||
}
|
||||
|
||||
function getDateSQL(field: string, unit: string, timezone?: string): string {
|
||||
if (timezone) {
|
||||
if (timezone && timezone !== 'utc') {
|
||||
return `to_char(date_trunc('${unit}', ${field} at time zone '${timezone}'), '${DATE_FORMATS[unit]}')`;
|
||||
}
|
||||
|
||||
return `to_char(date_trunc('${unit}', ${field}), '${DATE_FORMATS[unit]}')`;
|
||||
return `to_char(date_trunc('${unit}', ${field}), '${DATE_FORMATS_UTC[unit]}')`;
|
||||
}
|
||||
|
||||
function getDateWeeklySQL(field: string, timezone?: string) {
|
||||
|
||||
Reference in new issue
Block a user