Commit e4d1c89a authored by Yuliya Bozhko's avatar Yuliya Bozhko Committed by Gerrit Code Review
Browse files

Fix db_format_tsfield() returning value with offset on Postgres 9.2 and later (Bug #1353069)



Change-Id: I827851a16eba74d474234c21dd6b6afc2d06470c
Signed-off-by: default avatarYuliya Bozhko <yuliya.bozhko@totaralms.com>
parent 5c9a6ccb
...@@ -1432,7 +1432,7 @@ function db_format_timestamp($ts) { ...@@ -1432,7 +1432,7 @@ function db_format_timestamp($ts) {
function db_format_tsfield($field, $as = null) { function db_format_tsfield($field, $as = null) {
$tsfield = ''; $tsfield = '';
if (is_postgres()) { if (is_postgres()) {
$tsfield = "FLOOR(EXTRACT(EPOCH FROM $field))"; $tsfield = "FLOOR(EXTRACT(EPOCH FROM {$field} AT TIME ZONE CURRENT_SETTING('TIMEZONE')))";
} }
else if (is_mysql()) { else if (is_mysql()) {
$tsfield = "IF($field >= '1970-01-01', UNIX_TIMESTAMP($field), TIMESTAMPDIFF(SECOND, '1970-01-01', $field))"; $tsfield = "IF($field >= '1970-01-01', UNIX_TIMESTAMP($field), TIMESTAMPDIFF(SECOND, '1970-01-01', $field))";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment