[drupal-devel] [task] Introduce Daylight Saving Time for Drupal

praseodymium drupal-devel at drupal.org
Sun Jul 24 15:27:54 UTC 2005

Issue status update for 
Post a follow up: 

 Project:      Drupal
 Version:      cvs
 Component:    base system
 Category:     tasks
 Priority:     normal
 Assigned to:  crunchywelch
 Reported by:  killes at www.drop.org
 Updated by:   praseodymium
 Status:       patch

+1 for this feature, it's irritating to change timezones every time DST
is set.


Previous comments:

Sun, 26 Sep 2004 03:01:53 +0000 : killes at www.drop.org

Attachment: http://drupal.org/files/issues/dst.patch (6.04 KB)

Many people have wanted to have a Daylight Saving Time setting in the
past. If we use the "server time" modell (all times are displayed the
same around the world) this isn't all that hard to do.

I found a lot of usefull information here:

The patch introduces a new DST setting and uses it if the "Configurable
time zones" setting is switched off.


Sun, 26 Sep 2004 04:40:56 +0000 : gordon

This is a lovely patch, but you do realise that you have opened a can of

Daylight saving is a messy business, I had to write the Contestable
Electricity billing for a company here in Australia which had multiple
installations in multpile timezones, all with different daylight
savings rules, which impacted upon the bill. The way that dst is
legistated is very messy and here is Australia it is very messy.
Daylight savings don't follow state lines, as some towns that are very
close to the border may choose to follow the only the daylight saving
period of the next state, and when we had the olympics NSW went into
daylight savings months before anyone else. There are other examples of
weird things like even the 1 hour forward is not also true. I know that
in the 1999 change to daylight savings there was a small set of islands
north of New Zealand that went ahead by 2 hours as they wanted to be the
first into 2000.

>From what I can see of your patch it only allows for a single daylight
savings period for the entire system. Their can be situations where
there can be users from multiple countries and in different

I think that entire timezone system needs to looked at again, and maybe
re-implement it so that it will allow for dst. Maybe make it a bit more
user friendly so instead of setting up the timezone by name much like
how operating systems do it, and then this will automatically work out
the timezone.

+1 for this is something that would be good, but it still needs work.


Sun, 26 Sep 2004 14:13:27 +0000 : Anonymous

The patch works as it is now. I had good reason to limit its capability
to the setting where users cannot chose their own timezone. ;)
I also assume that a server administrator knows if he has dst or not. I
also didn't (yet) cater for all countries where dst is in use mainly
because some insist on not giving a sensible rule for the change dates.


Sun, 26 Sep 2004 22:54:40 +0000 : killes at www.drop.org

Attachment: http://drupal.org/files/issues/dst_0.patch (6.04 KB)

The last comment was mine.

After a code review by Kjartan I provide a slightly improved patch.

I want to stress that solving the DST issue in a "suits everybody"
manner isn't the intention of this patch.
It solves the problem for people who have chosen to let all times on
their site be displayed in the server's time setting. By covering a
large portion of the earth's landmass I hope to be able to help most
site admins.

It would be possible to extend the patch to allow users to chose their
DST setting, too. In my experience, however, users tend to not care
about time settings at all. This may be EUrocentric though, as we have
only one time zone. Feedback is welcome.


Mon, 27 Sep 2004 21:12:25 +0000 : drumm


>From a code review I think this is an excellent solution. Could use a
little more comments in the section that sets $node->date to explain
the (probably good) reasoning behind that chunk of code. I don't have
anything resembling a good set of tests so I did not apply the patch
and try it.


Tue, 25 Jan 2005 20:38:14 +0000 : killes at www.drop.org

I just want to point out that this patch still applies and would make
for a fine feature for Drupal 4.6...


Wed, 26 Jan 2005 16:46:21 +0000 : alliax

wouldn't hurt to have this feature in upcoming drupal.
I would use it for sure, my users are from the same place, with dst


Thu, 28 Apr 2005 16:12:36 +0000 : Sage

This is an incredibly useful feature and I would like to see it
incorporated into the next release (current release is 4.6.0).


Wed, 04 May 2005 16:06:51 +0000 : syntaxerror

Works beautifully.. I'm going to work on getting this to work with


Wed, 04 May 2005 17:53:36 +0000 : crunchywelch

I have just discussed with killes and rorris an enhancement to this
patch which I will implement. We have proposed putting the ical
timezone db
in core. We will implement a DST field in that db for each zone which
coreesponds with the zones in killes' patch here for dtermining whether
a zone is currently in dst or not. Currently, the 5 zones in the
drupal_is_dst() function in this patch will be the only regions
assigned to timezones. If more regions are desired they can be
submitted by the community.

To be clear, this must be implemented before additional development on
ical/event.module can proceed properly. We would like this to be in
core for 4.7, and move one more step with timezone handling in event
module to use this as well.



Wed, 04 May 2005 18:13:06 +0000 : tostinni

I agree to put more specific region to DST as it's easier for someone to
know which city DST he belongs than which DST Zone (Pacific Standard
I like pretty much the way that windows manage this.


Thu, 05 May 2005 02:45:52 +0000 : Jaza

The patch looks good... however, it doesn't take into account the fact
that in Australia, DST starts and ends at 2am on Sunday morning. So
these lines:

    case 4: // Australia
      // start of DST  (last Sunday in October)
      $dststart = strtotime("-1 week sunday GMT", strtotime("1
november $year GMT")) + $timezone;
      // end of DST (last Sunday in March)
      $dstend = strtotime("-1 week sunday GMT", strtotime("1
april $year GMT")) + $timezone;

Should read:

    case 4: // Australia
      // start of DST  (last Sunday in October at 2am)
      $dststart = strtotime("-1 week sunday GMT", strtotime("1
november $year GMT")) + 7200 + $timezone;
      // end of DST (last Sunday in March at 2am)
      $dstend = strtotime("-1 week sunday GMT", strtotime("1
april $year GMT")) + 7200 + $timezone;

There are also a whole lot more countries (and their specific DST
rules) on http://webexhibits.org/daylightsaving/g.html than are
implemented in this patch. I'd ultimately like to see an admin
interface to let the webmaster add additional DST rules for whatever
country they live in (or are developing for). These rules could be
entered in raw PHP, or using a somewhat friendlier interface.



Wed, 25 May 2005 06:11:32 +0000 : Steven

+1 on this patch. Catches most cases and at least provides a base for
others to work on.


Wed, 25 May 2005 07:13:36 +0000 : gordon

Do not take this the wrong what, but when it comes to dst, this is
exemely simplisict. 

What would be the best method of doing this is to use the Zone Info
files from libc. These not only have all the dst splits, but also all
the timezones, and would be the most acurate.

Have a look at Sources of Time Zone and Daylight Savings Data [1] whcih
has pointers to where all this information is.

Did you know that Australia has 21 different Timezones and DST areas.

If you could enter the same information from tzdata then this would be
the altermate dst system

[1] http://www.twinsun.com/tz/tz-link.htm


Wed, 25 May 2005 12:25:32 +0000 : jhriggs

There has sure been a lot of talk about DST and time zones lately.  All
I ask is that we hold off on committing anything for a bit.  I am
currently working on a project that will hopefully fix this issue
completely, correctly, and once and for all.  :-)

I am in the process of writing a pure PHP library that will be released
LGPL that uses the /real/ zoneinfo data files to handle any date (not
just Unix timestamps) in any time zone.  With this, site admins and/or
users will be able to select their real time zone (America/New_York vs.
our current GMT -500) and DST will inherently be handled without users
having to change their settings.  Much of the grunt work is already
done.  I still have to put all of the pieces together and make sure
everything is well documented.  As soon as I have tested everything to
my satisfaction, I will role a Drupal patch that we can hopefully get
tested and committed ASAP.  Of course I want to see this get into
Drupal first!  ;-)

I hope to have everything completed in the next couple of weeks, but
based on the way things have been going lately, I can't make any
promises.  It will definitely be done before 4.7, though...whatever it


Wed, 25 May 2005 12:47:07 +0000 : gordon


This sounds great, but I think we will still need a pure php version
that will be able to be used on hosted web sites where we will not be
able to get you library installed. It doesn't need to be as effient as
the php extension, as sites that at that big will be self hosted and be
able to install this library.

One question. Does you extension run on windows. If it does this is
another reason to have a pure php version.

This is really the method that should be employed.


Wed, 25 May 2005 12:53:32 +0000 : jhriggs

When I say "library," I just mean a collection of PHP files as opposed
to a single file.  There is nothing to be installed like an extension. 
This is pure PHP that will simply be part of the distribution (a handful
of .php files placed inside includes/zoneinfo or something like that). 
As this is pure PHP, it will work anywhere PHP does.  This will
essentially give us the benefit and functionality of using the TZ
variable on Unix without all of the problems associated with that (i.e.
not knowing what zones are available and what there names are, not being
available on Windows, etc.).


Wed, 25 May 2005 13:27:05 +0000 : gordon

This sounds good. If you would like someone who has done alot of stuff
with timezones and dst (mainly in the contestable electricity inductry
in australia, which is required for billing), I would be quite happy to
take a look.

The only problem that I see is that it sounds a little too messy for
core. maybe this could be made into a contributed module that can be
installed if people need the correct timezones.

However this is how the dst and timezones need to be done if we want to
get them correct. As I said before and I couldn't believe it, Australia
has 21 different timezones and dst areas. The timezone database needs
to be maintained.


Wed, 25 May 2005 14:41:40 +0000 : killes at www.drop.org

jhriggs, gordon: Please have a look at crunchywelch's dst implementation
for event.module (in 4.6 and cvs). We intend to push this into core.


Tue, 28 Jun 2005 20:11:48 +0000 : mfb

Great!  event_timezones.inc definitely needs to be in core, as it would
be used for both user and site configuration.  But it should include
everything from the unix zoneinfo libraries, e.g. timezone
abbreviations used by strftime(), so you can display "PDT" or "PST" 
instead of "America/Los_Angeles".  

so, a complete port of the zoneinfo libraries to PHP is probably what
is needed.  This would be used for site config, user config and events.


Tue, 05 Jul 2005 11:45:33 +0000 : glen

one idea, maybe use mysql timezone tables that are available since mysql

not sure how it's possible with licensing, but original tzdata is GPL
(at least according to Fedora Core 2 tzdata.spec) then mysql data table
contents should be too GPL.

good side is that it should work for windows too


Sat, 23 Jul 2005 02:08:23 +0000 : mfb

It would be great to use MySQL 4.1 as the solution but it probably isn't
(yet) possible for Drupal to require MySQL 4.1 when many webhosts are
still using MySQL 4.0.  We'll have to use our own zoneinfo library. 
Which by the way will need an update if the U.S. changes daylight
saving time.

More information about the drupal-devel mailing list