Closed (fixed)
Project:
Date
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Jul 2008 at 10:36 UTC
Updated:
7 Aug 2008 at 21:14 UTC
Jump to comment: Most recent file
While browsing the files trying to understand what does what, I came across an obvious error in date_sql_handler::db_tz_support() :
case 'mysqli':
$test = db_result(db_query("SELECT CONVERT_TZ('2008-02-15 12:00:00', 'UTC', 'US/Central')"));
if ($test == '2008-02-15 06:00:00') {
$has_support = TRUE;
}
break;
case 'pgsql':
$test = "TIMESTAMP WITH TIME ZONE '2008-02-15 12:00:00' AT TIME ZONE 'US/Central'";
if ($test == '2008-02-15 06:00:00') {
$has_support = TRUE;
}
db_result(db_query()) is missing in case 'pgsql'.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 279501.patch | 491 bytes | gdd |
Comments
Comment #1
gddThe actual query is incorrect too. I'm attempting to come up with a proper SQL query to do what is needed. Postgres seems to always want to convert everything to its current timezone, so converting between two random timezones in one SQL query is problematic, unless I'm totally missing the boat which is quite possible.
Comment #2
grub3 commentedThe correct SQL for PostgreSQL is:
SELECT '2008-02-15 12:00:00 UTC' AT TIME ZONE 'US/Central';You can also use PostgreSQL built-in funtion:
SELECT timezone('US/Central', '2008-02-15 12:00:00 UTC')Both queries return:
2008-02-15 06:00:00Patch:
I tested only the SQL.
Hope this helps.
JMP
Comment #3
grub3 commentedStatus: patch needs review.
Comment #4
gddThanks for that SQL, it is exactly what was needed.
I found a potential problem involving embedded quotes in your change to sql_tz(), but in the interests of tackling one thing per issue I think we should just address the problem in db_tz_support() right now. Patch attached, with a very minor formatting tweak. I'll open another issue for the sql_tz() problem.
Edit: and I decided not to pending a little more research.
Comment #5
karens commentedI committed the first part, the db_tz_support(). I'm unclear about the status of the second fix. Also, if it's correct, is it OK to capitalize TIMEZONE for consistency in the code?
Comment #6
gddjmpoure, can you elaborate on the change to timezone? It seems to me like the original should be fine but my experience with Postgres is not terribly extensive.
Comment #7
karens commentedNo response on this. If the remaining issue is just another valid way to structure the postgres code, there's no reason to change anything.
Comment #8
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.