Gossamer Forum
Home : Products : Gossamer Mail : Discussion :

daylight savings/standard time zones

Quote Reply
daylight savings/standard time zones
Is there any way for a user's timezone to be adjusted automatically for daylight savings time/standard time?

Maybe I am missing something, but it seems if the user is located in an area that recognizes daylight savings/standard time, and wants their email display time to reflect their local time correctly, they need to adjust their email time settings relative to GMT manually +/- 1 hour twice a year.
Quote Reply
Re: [zeke] daylight savings/standard time zones In reply to
Yes, that is correct. Currently Gossamer Mail only has time offset support, but we intend to add proper support in the future. We're currently testing an implementation with Gossamer Forum and if that works well, we'll be adding it to Gossamer Mail.

Quote Reply
Re: [brewt] daylight savings/standard time zones In reply to
ok, thanks for the info.

I've done a quick hack for my own purposes that I believe will work to automatically adjust timezones that use daylight savings time/standard time without too much trouble. changes to the existing code are very minor. so far I haven't found that it breaks anything. thought I would post it here in case anyone else was curious. this was all done on a unix-flavor server synced with NTP and auto-adjusting for daylight savings time/standard time. if you have a different server configuration this probably won't work. it might not work even if you do have a similar setup. any comments appreciated, especially if someone from Gossamer (or anyone else for that matter) can see that this implementation is a bad idea for some reason.

first, made current backups of everything, then added options to the users timezone selectors and admin section date_offset value selector. these new timezones will adjust automatically for daylight savings time, so no need to have the user select PST/PDT, EST/EDT, etc. we always just start with the default GMT offset for standard time in that particular timezone. the "1" at the end of the value indicates that this time zone should adjust for daylight savings/standard time; a "0" indicates that it should not. I have not fully verified what the "middle" value in these options is used for, so that may be an issue. I'm just using them as a way of determining if a particular value is selected and to indicate the default offset from GMT for my own info:

<option value="-540|AK -9:00|1">US Alaskan</option>
<option value="-420|AZ -7:00|0">US Arizona</option>
<option value="-360|CT -6:00|1">US Central</option>
<option value="-300|ET -5:00|1">US Eastern</option>
<option value="-600|HI -10:00|0">US Hawaiian-Aleutian</option>
<option value="-420|MT -7:00|1">US Mountain</option>
<option value="-480|PT -8:00|1">US Pacific</option>

appended extra value "|0" to existing GMT timezone options:

<option value="-720|GMT -12:00|0">GMT -12:00</option>
<option value="-660|GMT -11:00|0">GMT -11:00</option>


next, modified GMail/Messages.pm:


#begin original, commented-out this one line only
#my ($offset) = split /\|/ => $offset_cfg, 2;
#end original

#begin new
#dst_offset == 1 if the user is in a time zone that uses daylight savings time, or == 0 if not
#using split with limit of 3 will not break existing users because split will just quit if it
#runs out of delimiters
my ($offset,$gmt_offset,$dst_offset) = split /\|/ => $offset_cfg, 3;
$time += $offset * 60 if $offset; #original line
if ($dst_offset == 1)
#we add an hour if it is currently dst
#isdst will return 1 if we are in daylight savings time, otherwise 0
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$time += 3600 if ($isdst);
#end new

similar changes need to be made in GMail.pm and GMail/POP3/Manager.pm

adjust date_offset in local prefs.cfg file if necessary.

that's about it.

existing users can simply go to their options interface and select a new time zone if they want. any new users will have the new choices available.

Last edited by:

zeke: Sep 16, 2008, 12:10 AM