...making Linux just a little more fun!

### Two-cent Tip: Yo! zdump!

Ben Okopnik [ben at linuxgazette.net]

Sun, 14 Mar 2010 23:43:47 -0400

----- Forwarded message from "s. keeling" <keeling@nucleus.com> -----

I've yet again just discovered that tomorrow morning is "spring forward Day", so this may be apropos:

       alias dst="zdump -v Canada/Mountain | grep $(date '+%Y')"

Substitute your TZ for C/M, of course. Submit to 2cT?

    --
    * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *

Top Back

Ben Okopnik [ben at linuxgazette.net]

Mon, 15 Mar 2010 02:31:42 -0400

On Sun, Mar 14, 2010 at 11:43:47PM -0400, Benjamin Okopnik wrote:

    > ----- Forwarded message from "s. keeling" <keeling@nucleus.com> -----
    >
    > I've yet again just discovered that tomorrow morning is "spring
    > forward Day", so this may be apropos:
    >
    >    alias dst="zdump -v Canada/Mountain | grep $(date '+%Y')"
    >
    > Substitute your TZ for C/M, of course.

Even that last part can be automated:

    alias dst="zdump -v `cat /etc/timezone` | grep $(date '+%Y')"

    --
    * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *

Top Back

Breen Mullins [breen.mullins at gmail.com]

Mon, 15 Mar 2010 11:53:07 -0700

* Ben Okopnik <ben@linuxgazette.net> [2010-03-15 02:31 -0400]:

    >
    >Even that last part can be automated:
    >
    >``
    >alias dst="zdump -v `cat /etc/timezone` | grep $(date '+%Y')"
    >''
    >

For most of us that file should be /etc/localtime .

A large number of us had to worry about the time change on Sunday morning. The whole choir was there on time yesterday (!)

    --
    Breen Mullins
    <breen.mullins@gmail.com>

Top Back

Ben Okopnik [ben at okopnik.com]

Mon, 15 Mar 2010 15:55:43 -0400

On Mon, Mar 15, 2010 at 11:53:07AM -0700, Breen Mullins wrote:

    > * Ben Okopnik <ben@linuxgazette.net> [2010-03-15 02:31 -0400]:
    >
    > >
    > >Even that last part can be automated:
    > >
    > >``
    > >alias dst="zdump -v `cat /etc/timezone` | grep $(date '+%Y')"
    > >''
    >
    > For most of us that file should be /etc/localtime .

Breen, are you sure? My /etc/localtime is the actual timezone data - binary info - rather than the TZ string.

    --
    * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *

Top Back

Sam Bisbee [sbisbee at computervip.com]

Mon, 15 Mar 2010 16:55:06 -0400

On Mon, Mar 15, 2010 at 03:55:43PM -0400, Ben Okopnik wrote:

    > On Mon, Mar 15, 2010 at 11:53:07AM -0700, Breen Mullins wrote:
    > > * Ben Okopnik <ben@linuxgazette.net> [2010-03-15 02:31 -0400]:
    > >
    > > >
    > > >Even that last part can be automated:
    > > >
    > > >``
    > > >alias dst="zdump -v `cat /etc/timezone` | grep $(date '+%Y')"
    > > >''
    > >
    > > For most of us that file should be /etc/localtime .
    >
    > Breen, are you sure? My /etc/localtime is the actual timezone data -
    > binary info - rather than the TZ string.
    >

Ditto - /etc/localtime is binary data and /etc/timezone is the string representation ("America/New_York").

Cheers,

    --
    Sam Bisbee

Top Back

Breen Mullins [breen.mullins at gmail.com]

Mon, 15 Mar 2010 15:25:06 -0700

On Mon, Mar 15, 2010 at 12:55, Ben Okopnik <ben@okopnik.com> wrote:

    >
    > Breen, are you sure? My /etc/localtime is the actual timezone data -
    > binary info - rather than the TZ string.

On Fedora, there's no /etc/timezone. Just /etc/localtime (which is the binary data file).

zdump -v /etc/localtime returns the expected output, though.

Aren't distributions fun?

    --
    Breen Mullins
    <breen.mullins@gmail.com>

Top Back

Ben Okopnik [ben at linuxgazette.net]

Mon, 15 Mar 2010 19:44:21 -0400

On Mon, Mar 15, 2010 at 03:25:06PM -0700, Breen Mullins wrote:

    > On Mon, Mar 15, 2010 at 12:55, Ben Okopnik <ben@okopnik.com> wrote:
    > >
    > > Breen, are you sure? My /etc/localtime is the actual timezone data -
    > > binary info - rather than the TZ string.
    >
    > On Fedora, there's no /etc/timezone. Just /etc/localtime (which is the
    > binary data file).

I've just checked, and it pretty much what I recalled (Debian used to do it this way years ago): /etc/localtime is a link to the actual timezone data in /usr/share/zoneinfo. Not much help, there.

    > zdump -v /etc/localtime returns the expected output, though.

Perhaps that depends on what is expected.

    ben@Jotunheim:~$ zdump -v America/New_York | grep $(date '+%Y')
    America/New_York  Sun Mar 14 06:59:59 2010 UTC = Sun Mar 14 01:59:59 2010 EST isdst=0 gmtoff=-18000
    America/New_York  Sun Mar 14 07:00:00 2010 UTC = Sun Mar 14 03:00:00 2010 EDT isdst=1 gmtoff=-14400
    America/New_York  Sun Nov  7 05:59:59 2010 UTC = Sun Nov  7 01:59:59 2010 EDT isdst=1 gmtoff=-14400
    America/New_York  Sun Nov  7 06:00:00 2010 UTC = Sun Nov  7 01:00:00 2010 EST isdst=0 gmtoff=-18000
    ben@Jotunheim:~$ zdump -v /usr/share/zoneinfo/EDT
    /usr/share/zoneinfo/EDT  Fri Dec 13 20:45:52 1901 UTC = Fri Dec 13 20:45:52 1901 isdst=0 gmtoff=0
    /usr/share/zoneinfo/EDT  Sat Dec 14 20:45:52 1901 UTC = Sat Dec 14 20:45:52 1901 isdst=0 gmtoff=0
    /usr/share/zoneinfo/EDT  Mon Jan 18 03:14:07 2038 UTC = Mon Jan 18 03:14:07 2038 isdst=0 gmtoff=0
    /usr/share/zoneinfo/EDT  Tue Jan 19 03:14:07 2038 UTC = Tue Jan 19 03:14:07 2038 isdst=0 gmtoff=0
    ben@Jotunheim:~$ zdump -v /usr/share/zoneinfo/EDT | grep $(date '+%Y')
    ben@Jotunheim:~$

Neither of the last two gives you the time switch-over point, which was, I think, Stephen's whole point.

    > Aren't distributions fun?

Heh. I'm sure that there's a way to get the same thing on a Fedora/CentOS system, but you're right: my adaptation of this script will only work on systems that have a file containing that TZ string (note that 'EST', etc., won't work; it has to be the 'Country/City' variety.) His version is distro-independent, though - assuming that all distros have 'zdump', of course.

    --
    * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *

Top Back