mirror of
https://github.com/directus/directus.git
synced 2026-01-26 14:07:56 -05:00
Fix SQLite date functions (#10270)
This commit is contained in:
@@ -3,35 +3,35 @@ import { Knex } from 'knex';
|
||||
|
||||
export class DateHelperSQLite extends DateHelper {
|
||||
year(table: string, column: string): Knex.Raw {
|
||||
return this.knex.raw("strftime('%Y', ??.??)", [table, column]);
|
||||
return this.knex.raw("strftime('%Y', ??.?? / 1000, 'unixepoch')", [table, column]);
|
||||
}
|
||||
|
||||
month(table: string, column: string): Knex.Raw {
|
||||
return this.knex.raw("strftime('%m', ??.??)", [table, column]);
|
||||
return this.knex.raw("strftime('%m', ??.?? / 1000, 'unixepoch')", [table, column]);
|
||||
}
|
||||
|
||||
week(table: string, column: string): Knex.Raw {
|
||||
return this.knex.raw("strftime('%W', ??.??)", [table, column]);
|
||||
return this.knex.raw("strftime('%W', ??.?? / 1000, 'unixepoch')", [table, column]);
|
||||
}
|
||||
|
||||
day(table: string, column: string): Knex.Raw {
|
||||
return this.knex.raw("strftime('%d', ??.??)", [table, column]);
|
||||
return this.knex.raw("strftime('%d', ??.?? / 1000, 'unixepoch')", [table, column]);
|
||||
}
|
||||
|
||||
weekday(table: string, column: string): Knex.Raw {
|
||||
return this.knex.raw("strftime('%w', ??.??)", [table, column]);
|
||||
return this.knex.raw("strftime('%w', ??.?? / 1000, 'unixepoch')", [table, column]);
|
||||
}
|
||||
|
||||
hour(table: string, column: string): Knex.Raw {
|
||||
return this.knex.raw("strftime('%H', ??.??)", [table, column]);
|
||||
return this.knex.raw("strftime('%H', ??.?? / 1000, 'unixepoch')", [table, column]);
|
||||
}
|
||||
|
||||
minute(table: string, column: string): Knex.Raw {
|
||||
return this.knex.raw("strftime('%M', ??.??)", [table, column]);
|
||||
return this.knex.raw("strftime('%M', ??.?? / 1000, 'unixepoch')", [table, column]);
|
||||
}
|
||||
|
||||
second(table: string, column: string): Knex.Raw {
|
||||
return this.knex.raw("strftime('%S', ??.??)", [table, column]);
|
||||
return this.knex.raw("strftime('%S', ??.?? / 1000, 'unixepoch')", [table, column]);
|
||||
}
|
||||
|
||||
parse(date: string): string {
|
||||
|
||||
Reference in New Issue
Block a user