Closed (fixed)
Project:
Event
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
30 Mar 2004 at 06:34 UTC
Updated:
2 May 2004 at 19:20 UTC
Jump to comment: Most recent file
Most of the events which I created show the correct time. I'm in GMT - 8:00. However, I recently created some events on April 5, which is after daylight savings time changes. This events show up an hour later than the created time.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | event.module_0.patch | 4.12 KB | nereocystis |
| #6 | event.module.patch | 4.15 KB | nereocystis |
Comments
Comment #1
Steve Dondley commentedThis also occurs in 4.4.0. It appears only to occur in the "Upcoming Events" block. Times that appear in the large calendar are correct. However, I can't be sure on this because I have customized my event.module.
Comment #2
Steve Dondley commentedYeah, ignore the above about 4.4.0. It was my own customized code causing the problem.
Comment #3
nereocystis commentedI'm using postgresql under 4.3, if that matters.
I have seen some discussion about timezone problems with Drupal as a whole. See "timezone handling is still busted. Perhaps there are fixes in 4.4, but the Changelog doesn't mention a fix.
My timezone options are limited to GMT offsets, which doesn't consider the starting date of daylight savings time. Arizona, for example, doesn't use daylight savings time, though it uses Mountain Standard time during the winter.
This line in event.module under 4.4 concerns me:
$node->start = gmmktime($hour, $node->minute, 0, $node->month, $node->day, $node->year) - $GLOBALS['user']->timezone;
If I choose a date after daylight savings time changes, with my GMT - 8:00 setting, then 8 hours are added to the start time, even though the time zone will be GMT - 7:00 when the event actually occurs.
I suggest using standard *nix time zones, which are well thought out, rather than the direct GMT offsets which drupal currently uses. However, this change requires more than just event modifications.
I'm afraid that the fix may require a lot of work,
Comment #4
killes@www.drop.org commentedTimezones and DST are a major PITA. I've started some work on removing time zones from event.module in the HEAD branch. Now I am stuck with DST...
I think it would be easier to use an SQL date field instead of unix timestamps. Does postgres support such fields?
Comment #5
nereocystis commentedI was thinking the same thing. I suggest a field which combines time and date into one field. postgresql's documentation explains why, in a link I include below.
For postgresql, the best option may be
tswtz timestamp with time zone,
Each connection may have its own time zone. I'm not sure how to handle this within Drupal, but it should be doable. Here's a sample select statement, where tswtz is of type "timestamp with time zone". The right columns adds 5 days, but because of daylight savings time, the time part is off an hour, which is the way it should be.
wilma=# select tswtz, tswtz + '5 00:00:00' from fred;
tswtz | ?column?
-------------------------------+-------------------------------
2004-03-30 15:30:06.761742-08 | 2004-04-04 16:30:06.761742-07
PostgreSQL Date/Time documentation
Here's a quote from the documentation:
The type time with time zone is defined by the SQL standard, but the definition exhibits properties which lead to questionable usefulness. In most cases, a combination of date, time, timestamp without time zone, and timestamp with time zone should provide a complete range of date/time functionality required by any application.
Comment #6
nereocystis commentedHere's a quickie fix, which will work until timezones are really fixed. The fix is somewhat ugly, but less ugly than the current solution.
I have tested this in drupal-4.3.2
I added a function event_format_date, which is a slight modification of format_date. I placed the function in event.module. This function uses gmdate, rather than date. gmdate won't use the local timezone, unlike date. The timezone is added to timestamp, as it should be. For event, timestamp is the field start from the table event. Every instance of format_date in event.module is replaced with event_format_date. Maybe the function should be named gm_format_date. I'm tempted to remove date("Z") from this function, but this only gets called when timezone is null.
I also set timezone for user 0, which is the anonymous user.
update users set timezone=-28800 where uid = 0;
and set a default for timezone:
alter tables users alter timezone set default -28800;
Make sure that all users have timezone set. Perhaps you need:
update users set timezone=-28800 where timezone is null;
I am in Pacific time, which is -28800 in winter, and -25200 in summer. I have just set the time zone to winter time. This is ugly, but until there is a good timezone fix this will mostly work. Unfortunately, users may try to change their timezone to reflect daylight savings time; this will cause problems. I use winter time, because that makes start use UTC, which seems better.
You should choose your own favorite timezone, replacing -28800.
You may need to modify the start time of your events after this change.
Here is my patch against the 4.3 event.
Comment #7
nereocystis commentedMy patch is the attachment to the previous post, which is probably obvious. However, my posting suggest that the patch follows the post.
Comment #8
nereocystis commentedLet me try a slightly different patch. There's only one line difference. I removed the date("Z") correction, because this was applied when timezone was set to 0, not just to null. So a person in UTC would be reset to using the local timezone, which is really not correct.
The new patch is attached.
Comment #9
killes@www.drop.org commentedI don't think that I want to fix this in 4.3.2. I am currenly working on a fix for the cvs version (introducing a event_format_date function myself). Get a cvs checkout to see how far I got.
The problem with all this time zones is that you have to rely on the user's ability and willingness to tell you in which time zone he is. What I want to do is introduce an option to change the date storage to a format that does not use timestamps but sql date fields. In this fields I would simply store the date that the submitter specifies and tell the viewers that they need to interprete it according to the location given. This will also eliminate the daylight savings time issue.
Comment #10
nereocystis commentedYour solution is definitely better. I needed a quick solution, and didn't want to deviate too much from the standard release. I look forward to seeing your solution.
Comment #11
Brian@brianpuccio.net commentedkilles:
In saying that viewers...need to interprete it according to the location given you mean posts will display "Posted 3:15pm EST" regardless of what timezone the reader is? And that the reader will than have to count hours to see when that is relative to his timezone as well as factor in DST for possibly his time zone as well as the poster? I don't think this will appeal to Joe Internet user. He doesn't want to count hours between time zones.
what about asking each person in their profile what time zone they are in and whether or not they observe DST or not. Ask the admin what time zone the server is in and whether or not DST is observed. Than let Drupal do the hour counting for each display of time.
Or just have a "what time is closest to your time?" selction box with multiples of 30 minutes (some in between zones, I think, out there) and let users pick whatever makes the times match up to their local time.
Or we get rid of DST, all time keeping as we currently know it and swtich to a time system that is base 10.
For what it's worth the phpBB group has a mod to take care of this, apparently they are having issues with DST as well.
Comment #12
jxs2151 commentedI would think that making the user set a timezone during account creation would go a long way toward having all (most?) users set a timezone. While this does not solve the DST issues it will allow us to assume that users have set a timezone and we can go about trying to find a fix from that baseline.
The reason I mention having users choose a TZ during account creation is that if it is not done then it will not get done. I am not sure what others are seeing but I have found a %0 rate of users setting a TZ after account creation on my sites. I don't think we need to force them to do so but at least have it figure prominently on the account creation page, perhaps with a note explaining the importance of them setting a TZ.
Unfortunately I have no answer in code or otherwise for how to handle this situation. I work for a big three ERP vendor that is still struggling with timezones, DST, timestamps, etc. I don't know the exact approach but I know that we went with a "system time" for timestamping and internal timekeeping. I think the approach was very dependant on have the users timezone set correctly. Once these two things were done, standard timezone code was used for things like Daylight savings time changes.
Comment #13
killes@www.drop.org commentedI think I fixed this in 4.4 and cvs.
Chose "No: Times are saved relative to the server's time" for "Timezone handling".
Comment #14
(not verified) commented