mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
Merge branch 'next' into develop
This commit is contained in:
commit
aa709c3e70
@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Col, Formatter } from './formatter';
|
import { Col, Formatter } from './formatter';
|
||||||
|
import moment from 'moment-timezone';
|
||||||
|
|
||||||
export class MySQLFormatter extends Formatter {
|
export class MySQLFormatter extends Formatter {
|
||||||
convertFormat(format: string) {
|
convertFormat(format: string) {
|
||||||
@ -21,14 +22,10 @@ export class MySQLFormatter extends Formatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
formatDate(field: Col, format: string, timezoneOffset?: string) {
|
formatDate(field: Col, format: string, timezoneOffset?: string) {
|
||||||
const timezone = this.getTimezoneByOffset(timezoneOffset);
|
const tz = moment.tz(process.env.TZ || 'UTC').format('Z');
|
||||||
format = this.convertFormat(format);
|
format = this.convertFormat(format);
|
||||||
if (timezone) {
|
if (timezoneOffset && tz !== timezoneOffset) {
|
||||||
return this.sequelize.fn(
|
return this.sequelize.fn('date_format', this.sequelize.fn('convert_tz', field, tz, timezoneOffset), format);
|
||||||
'date_format',
|
|
||||||
this.sequelize.fn('convert_tz', field, process.env.TZ || 'UTC', timezone),
|
|
||||||
format,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return this.sequelize.fn('date_format', field, format);
|
return this.sequelize.fn('date_format', field, format);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user