[buug] daylight saving changes, UNIX/LINUX/... time, etc.

Michael Paoli Michael.Paoli at cal.berkeley.edu
Sat Mar 10 09:48:47 PST 2007


Quoting John de la Garza:

> I like this better.  Thanks a million.
> On Mar 6, 2007, at 12:02 PM, Bruce Ferrell wrote:
> > I'm not sure if FC3 is still being maintained, so here's a how-to
> > to bring your zone files up to date
> > http://www.linux-watch.com/news/NS6300294422.html
> > John de la Garza wrote:
> >> I have a fedora core 3 box I need to update for the new daylight
> >> savings time
> >>  From what I can tell I can just run:
> >> up2date tzdata
> >> to fix it
> >> then maybe system-config-date if it is needed
> >> is this correct?

A fairly good article,
> > http://www.linux-watch.com/news/NS6300294422.html
with a lot of good information, ... but it gets a lot of details not
exactly correct.

Fist of all, the history of DST isn't that smooth and uniform.  This
change (enacted in 2005, taking effect starting in 2007) isn't the
first time the DST rules/law(s) have significantly changed ... and
not even the first significant changes since Uniform Time Act became
effective in 1966.
http://en.wikipedia.org/wiki/History_of_time_in_the_United_States#History_of_DST_in_the_US
Also, the new changes for DST aren't necessarily permanent.  Not only
is there the issue of the legislature potentially changing things, but
the Energy Policy act of 2005 contains explicit mention of "Right to
Revert":
"
SEC. 110. DAYLIGHT SAVINGS.

    (a) Amendment.--Section 3(a) of the Uniform Time Act of 1966 (15
U.S.C. 260a(a)) is amended--
            (1) by striking ``first Sunday of April'' and inserting
        ``second Sunday of March''; and
            (2) by striking ``last Sunday of October'' and inserting
        ``first Sunday of November''.

    (b) Effective Date.--Subsection (a) <<NOTE: 15 USC 260a
note.>> shall take effect 1 year after the date of enactment of this Act
or March 1, 2007, whichever is later.

    (c) Report to Congress.--Not <<NOTE: 15 USC 260a note.>> later than
9 months after the effective date stated in subsection (b), the
Secretary shall report to Congress on the impact of this section on
energy consumption in the United States.

    (d) Right to Revert.--Congress retains the right to revert the
Daylight Saving Time back to the 2005 time schedules once the Department
study is complete.
"
http://frwebgate.access.gpo.gov/cgi-bin/getdoc.cgi?dbname=109_cong_public_laws&docid=f:publ058.109

And on to LINUX, UNIX, times and clocks, etc.

Historically, UNIX required a working real-time clock - specifically
a hardware clock that would generally track the time even when the
system was powered down (e.g. battery backed), or certainly at least
would provide the correct time when the system was powered up - and
before the operating system even began to boot.  This clock would
always be set to UTC.  Over the years, particularly with different
hardware, and LINUX, this "requirement" has often changed slightly.
Some flavors of *nix (UNIX/LINUX/BSD/...) would boot - or at least
start booting - even without a real-time hardware clock.  They would
generally require manual intervention (prompt for correct time) early
in the boot-up sequence, and would not boot until that data was
entered (typically prompted for on the console).  Some *nix flavors
will fall back to that behavior at boot if they detect a failure in
the real-time hardware clock.  Some *nix flavors would also, when
booting, at least initially use the time of last sync of the root
filesystem to set the system time (not to be confused with the
real-time hardware clock - I'll get to system time in a bit).  They
would typically do this before attempting to read the real-time
hardware clock and/or prompting for a correct date/time at boot.
While reading the sync time from the root filesystem is only a very
crude approximation of what the current date/time actually is, it
does have the advantage of avoiding the nastiness that tends to
happen if the system is ever run with a system time that is earlier
than a system time it has already used before.

Hardware clock is UTC?  Historically, but not necessarily any more.
It depends on both hardware, and convention (and/or operating system
flavor).  Most notably, with the advent of x86 PC hardware, certain
other relatively predominant operating systems had a convention of
having the hardware clock set to local time, rather than UTC.
Consequently, various *nix flavors have different UTC vs. local
conventions for the real-time hardware clock.  Some require the
real-time hardware clock be set to local time, others can be
configured to have it set to either UTC or local time, and there may
be some that require it to be UTC (none specifically jump to mind,
but it is possible).  Most LINUX distributions allow either
convention, many of them default to local; UTC can be quite
advantageous for greater compatibility with UNIX and for managing
systems distributed across multiple timezones.  Conversely, local can
be advantageous for dual (or more) boot systems, where there may be
other operating systems present that require it be set to local time.

System time.  In *nix, the operating system has a system time.  It's
tracked in seconds since the epoch (excluding leap seconds, if I
recall correctly).  For *nix, the epoch is 1970-01-01 00:00:00 UTC.
When the system is booted, the system time is set (typically via
reading the real-time hardware clock).  Once the system time has been
set, for the most part, the time of the real-time clock, and the
system time, are relatively independent.  For most all purposes, the
operating system uses the system time, and does not refer back to or
change the real-time clock.  To actually change/set the real-time
clock (which typically doesn't need to be done too often - especially
if it's fairly accurate and set to UTC) is accomplished by various
means, depending on the *nix flavor.  E.g. for UNIX, the date(1)
command sets both the system time and the real-time hardware clock -
and it makes the appropriate conversions and such so each clock is
set to its proper time (seconds since the epoch, and local or UTC
time, respectively), and for LINUX, there are distinct commands (e.g.
hwclock(8)) which are used to set the hardware clock.  We'll get to
these conversions in a bit (that's where all the DST and timezone
excitement and such comes in).

DST, timezones, conversions, and all that excitement.  The operating
system mostly just deals with the system time - as far as the
operating system is concerned, that defines what the current time is.
 To deal with more conventional time information (date, hour,
minutes, seconds, timezone, etc.), *nix does conversions between such
time data and seconds since the epoch.  For non-ancient *nix, this is
mostly covered via timezone files, and also a timezone definition
(e.g. 'which one is *my* timezone?').  The timezone definition is
handled slightly differently among *nix flavors.  Some always use the
TZ environment variable to specify the timezone, and if it's not
present, the zone will be presumed to be UTC (or GMT0).  For other
flavors (e.g. probably most or all LINUX distributions), the default
timezone is specified via a file (e.g. containing or linked to a
timezone data file), and if TZ isn't set in the environment, the
default will be the zone specified in that file.  Note also that *nix
systems will generally define a default local timezone - e.g. by
setting TZ (such as in /etc/profile or similar) or setting some
default file, so that by default, most or all processes will pick up
the default local timezone, unless they (or a parent process of
theirs) takes explicit action to select a different timezone (by
setting TZ to something else or unsetting it).  Most commonly, the
local/default timezone is set to the timezone corresponding to where
the system is physically located - but that's not always the case
(e.g.  organizations spanning multiple zones may "standardize" their
systems upon a single "local" zone or use UTC, and/or systems that
are rather to quite mobile may use a particular zone rather than
quite regularly changing the default).

So, ... what's most critical to *nix, for proper DST handling and the
like, are these timezone files.  These files define offsets and
transitions relative to the epoch, for their applicable zone, and
also cover the name of the zone (by the file's relative pathname) and
also the name(s)/abbreviation(s) used by the zone for both standard
time, and also for Daylight Saving Time / Summertime.  For well
behaved programs (recommended practice) on *nix, the programs do all
their time conversions via standard library calls, which in turn use
the timezone files to know how to convert from any time in any zone,
to seconds since the epoch, and vice versa.  If the timezone files
are correct and current, and the libraries and such work properly,
and the programs all follow this practice, then updating the timezone
files is all that's needed for dealing with changes to DST rules/law
(e.g. if your timezone files covering the US predate the Energy Act
of 2005, they aren't correct for at least 2007).

Unfortunately not all software is ideal, so there are other
"gottchas".  Historically, UNIX didn't have timezone files - it was
all coded within libraries, and these libraries were even statically
linked into programs.  In such cases, the programs themselves had to
be updated.  Also, some other programs/applications may not follow
current recommended practice regarding handling of timezones, DST,
time/date conversions, etc.  E.g. if the program has its own
hardcoded idea of what the DST rules are, and it's not coded to cover
the more current stuff, the program will need to be updated.  Some of
the key areas to be aware of for such items on *nix, include Java,
and at least some databases (many of which have their own time/date
routines and coding).

Note the variation in when Daylight/Standard time transitions have
and will take place.  If everything properly (directly or indirectly)
does its calculations and conversions via proper timezone files, then
this is all then well and fully covered by having a timezone file
which is correct for past, present, and thus far know future
rules/laws.
$ zdump -v US/Pacific | sed -ne '/ 1970 /,/ Nov .* 2007 PST /{;s/^.* UTC = //p;}'
Sun Apr 26 01:59:59 1970 PST isdst=0 gmtoff=-28800
Sun Apr 26 03:00:00 1970 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:59:59 1970 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:00:00 1970 PST isdst=0 gmtoff=-28800
Sun Apr 25 01:59:59 1971 PST isdst=0 gmtoff=-28800
Sun Apr 25 03:00:00 1971 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:59:59 1971 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:00:00 1971 PST isdst=0 gmtoff=-28800
Sun Apr 30 01:59:59 1972 PST isdst=0 gmtoff=-28800
Sun Apr 30 03:00:00 1972 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:59:59 1972 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:00:00 1972 PST isdst=0 gmtoff=-28800
Sun Apr 29 01:59:59 1973 PST isdst=0 gmtoff=-28800
Sun Apr 29 03:00:00 1973 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:59:59 1973 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:00:00 1973 PST isdst=0 gmtoff=-28800
Sun Jan  6 01:59:59 1974 PST isdst=0 gmtoff=-28800
Sun Jan  6 03:00:00 1974 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:59:59 1974 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:00:00 1974 PST isdst=0 gmtoff=-28800
Sun Feb 23 01:59:59 1975 PST isdst=0 gmtoff=-28800
Sun Feb 23 03:00:00 1975 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:59:59 1975 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:00:00 1975 PST isdst=0 gmtoff=-28800
Sun Apr 25 01:59:59 1976 PST isdst=0 gmtoff=-28800
Sun Apr 25 03:00:00 1976 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:59:59 1976 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:00:00 1976 PST isdst=0 gmtoff=-28800
Sun Apr 24 01:59:59 1977 PST isdst=0 gmtoff=-28800
Sun Apr 24 03:00:00 1977 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:59:59 1977 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:00:00 1977 PST isdst=0 gmtoff=-28800
Sun Apr 30 01:59:59 1978 PST isdst=0 gmtoff=-28800
Sun Apr 30 03:00:00 1978 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:59:59 1978 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:00:00 1978 PST isdst=0 gmtoff=-28800
Sun Apr 29 01:59:59 1979 PST isdst=0 gmtoff=-28800
Sun Apr 29 03:00:00 1979 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:59:59 1979 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:00:00 1979 PST isdst=0 gmtoff=-28800
Sun Apr 27 01:59:59 1980 PST isdst=0 gmtoff=-28800
Sun Apr 27 03:00:00 1980 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:59:59 1980 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:00:00 1980 PST isdst=0 gmtoff=-28800
Sun Apr 26 01:59:59 1981 PST isdst=0 gmtoff=-28800
Sun Apr 26 03:00:00 1981 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:59:59 1981 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:00:00 1981 PST isdst=0 gmtoff=-28800
Sun Apr 25 01:59:59 1982 PST isdst=0 gmtoff=-28800
Sun Apr 25 03:00:00 1982 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:59:59 1982 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:00:00 1982 PST isdst=0 gmtoff=-28800
Sun Apr 24 01:59:59 1983 PST isdst=0 gmtoff=-28800
Sun Apr 24 03:00:00 1983 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:59:59 1983 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:00:00 1983 PST isdst=0 gmtoff=-28800
Sun Apr 29 01:59:59 1984 PST isdst=0 gmtoff=-28800
Sun Apr 29 03:00:00 1984 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:59:59 1984 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:00:00 1984 PST isdst=0 gmtoff=-28800
Sun Apr 28 01:59:59 1985 PST isdst=0 gmtoff=-28800
Sun Apr 28 03:00:00 1985 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:59:59 1985 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:00:00 1985 PST isdst=0 gmtoff=-28800
Sun Apr 27 01:59:59 1986 PST isdst=0 gmtoff=-28800
Sun Apr 27 03:00:00 1986 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:59:59 1986 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:00:00 1986 PST isdst=0 gmtoff=-28800
Sun Apr  5 01:59:59 1987 PST isdst=0 gmtoff=-28800
Sun Apr  5 03:00:00 1987 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:59:59 1987 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:00:00 1987 PST isdst=0 gmtoff=-28800
Sun Apr  3 01:59:59 1988 PST isdst=0 gmtoff=-28800
Sun Apr  3 03:00:00 1988 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:59:59 1988 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:00:00 1988 PST isdst=0 gmtoff=-28800
Sun Apr  2 01:59:59 1989 PST isdst=0 gmtoff=-28800
Sun Apr  2 03:00:00 1989 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:59:59 1989 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:00:00 1989 PST isdst=0 gmtoff=-28800
Sun Apr  1 01:59:59 1990 PST isdst=0 gmtoff=-28800
Sun Apr  1 03:00:00 1990 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:59:59 1990 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:00:00 1990 PST isdst=0 gmtoff=-28800
Sun Apr  7 01:59:59 1991 PST isdst=0 gmtoff=-28800
Sun Apr  7 03:00:00 1991 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:59:59 1991 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:00:00 1991 PST isdst=0 gmtoff=-28800
Sun Apr  5 01:59:59 1992 PST isdst=0 gmtoff=-28800
Sun Apr  5 03:00:00 1992 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:59:59 1992 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:00:00 1992 PST isdst=0 gmtoff=-28800
Sun Apr  4 01:59:59 1993 PST isdst=0 gmtoff=-28800
Sun Apr  4 03:00:00 1993 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:59:59 1993 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:00:00 1993 PST isdst=0 gmtoff=-28800
Sun Apr  3 01:59:59 1994 PST isdst=0 gmtoff=-28800
Sun Apr  3 03:00:00 1994 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:59:59 1994 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:00:00 1994 PST isdst=0 gmtoff=-28800
Sun Apr  2 01:59:59 1995 PST isdst=0 gmtoff=-28800
Sun Apr  2 03:00:00 1995 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:59:59 1995 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:00:00 1995 PST isdst=0 gmtoff=-28800
Sun Apr  7 01:59:59 1996 PST isdst=0 gmtoff=-28800
Sun Apr  7 03:00:00 1996 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:59:59 1996 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:00:00 1996 PST isdst=0 gmtoff=-28800
Sun Apr  6 01:59:59 1997 PST isdst=0 gmtoff=-28800
Sun Apr  6 03:00:00 1997 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:59:59 1997 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:00:00 1997 PST isdst=0 gmtoff=-28800
Sun Apr  5 01:59:59 1998 PST isdst=0 gmtoff=-28800
Sun Apr  5 03:00:00 1998 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:59:59 1998 PDT isdst=1 gmtoff=-25200
Sun Oct 25 01:00:00 1998 PST isdst=0 gmtoff=-28800
Sun Apr  4 01:59:59 1999 PST isdst=0 gmtoff=-28800
Sun Apr  4 03:00:00 1999 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:59:59 1999 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:00:00 1999 PST isdst=0 gmtoff=-28800
Sun Apr  2 01:59:59 2000 PST isdst=0 gmtoff=-28800
Sun Apr  2 03:00:00 2000 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:59:59 2000 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:00:00 2000 PST isdst=0 gmtoff=-28800
Sun Apr  1 01:59:59 2001 PST isdst=0 gmtoff=-28800
Sun Apr  1 03:00:00 2001 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:59:59 2001 PDT isdst=1 gmtoff=-25200
Sun Oct 28 01:00:00 2001 PST isdst=0 gmtoff=-28800
Sun Apr  7 01:59:59 2002 PST isdst=0 gmtoff=-28800
Sun Apr  7 03:00:00 2002 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:59:59 2002 PDT isdst=1 gmtoff=-25200
Sun Oct 27 01:00:00 2002 PST isdst=0 gmtoff=-28800
Sun Apr  6 01:59:59 2003 PST isdst=0 gmtoff=-28800
Sun Apr  6 03:00:00 2003 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:59:59 2003 PDT isdst=1 gmtoff=-25200
Sun Oct 26 01:00:00 2003 PST isdst=0 gmtoff=-28800
Sun Apr  4 01:59:59 2004 PST isdst=0 gmtoff=-28800
Sun Apr  4 03:00:00 2004 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:59:59 2004 PDT isdst=1 gmtoff=-25200
Sun Oct 31 01:00:00 2004 PST isdst=0 gmtoff=-28800
Sun Apr  3 01:59:59 2005 PST isdst=0 gmtoff=-28800
Sun Apr  3 03:00:00 2005 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:59:59 2005 PDT isdst=1 gmtoff=-25200
Sun Oct 30 01:00:00 2005 PST isdst=0 gmtoff=-28800
Sun Apr  2 01:59:59 2006 PST isdst=0 gmtoff=-28800
Sun Apr  2 03:00:00 2006 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:59:59 2006 PDT isdst=1 gmtoff=-25200
Sun Oct 29 01:00:00 2006 PST isdst=0 gmtoff=-28800
Sun Mar 11 01:59:59 2007 PST isdst=0 gmtoff=-28800
Sun Mar 11 03:00:00 2007 PDT isdst=1 gmtoff=-25200
Sun Nov  4 01:59:59 2007 PDT isdst=1 gmtoff=-25200
Sun Nov  4 01:00:00 2007 PST isdst=0 gmtoff=-28800
$ 



More information about the buug mailing list