mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
fix UTC issues
This commit is contained in:
parent
004ccdc22f
commit
a15d0ca94a
6 changed files with 35 additions and 21 deletions
|
|
@ -12,11 +12,11 @@ import { filtersToArray } from './params';
|
|||
const log = debug('umami:prisma');
|
||||
|
||||
const MYSQL_DATE_FORMATS = {
|
||||
minute: '%Y-%m-%dT%H:%i:00Z',
|
||||
hour: '%Y-%m-%dT%H:00:00Z',
|
||||
day: '%Y-%m-%dT00:00:00Z',
|
||||
month: '%Y-%m-01T00:00:00Z',
|
||||
year: '%Y-01-01T00:00:00Z',
|
||||
minute: '%Y-%m-%dT%H:%i:00',
|
||||
hour: '%Y-%m-%d %H:00:00',
|
||||
day: '%Y-%m-%d',
|
||||
month: '%Y-%m-01',
|
||||
year: '%Y-01-01',
|
||||
};
|
||||
|
||||
const POSTGRESQL_DATE_FORMATS = {
|
||||
|
|
@ -82,15 +82,16 @@ function getDateSQL(field: string, unit: string, timezone?: string): string {
|
|||
}
|
||||
}
|
||||
|
||||
function getDateWeeklySQL(field: string) {
|
||||
function getDateWeeklySQL(field: string, timezone?: string) {
|
||||
const db = getDatabaseType();
|
||||
|
||||
if (db === POSTGRESQL) {
|
||||
return `concat(extract(dow from ${field}), ':', to_char(${field}, 'HH24'))`;
|
||||
return `concat(extract(dow from (${field} at time zone '${timezone}')), ':', to_char((${field} at time zone '${timezone}'), 'HH24'))`;
|
||||
}
|
||||
|
||||
if (db === MYSQL) {
|
||||
return `date_format(${field}, '%w:%H')`;
|
||||
const tz = moment.tz(timezone).format('Z');
|
||||
return `date_format(convert_tz(${field},'+00:00','${tz}'), '%w:%H')`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue