LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-23-2009, 02:16 PM   #1
suryaemlinux
Member
 
Registered: Mar 2009
Distribution: CentOS, Fedora
Posts: 34

Rep: Reputation: 0
How to read the Daylight Saving Start date in C/C++?


Hi folks,
I would like to read the start date and end date of the Daylight Saving Time for the given timezone in the given year. I'm using Linux 2.6.xx Kernel. What's the function in C/C++ to read the start of the Daylight Saving date and end of Daylight saving date?

For Example, in Pacific Time (US & Canada) the Daylight Start date for the year 2009 is Mar 9,2009 and it ended on Nov 1, 2009. I need a C/C++ function to read these dates.

Thanks in Advance,
Surya

Last edited by suryaemlinux; 12-23-2009 at 02:17 PM.
 
Old 12-23-2009, 03:17 PM   #2
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 178Reputation: 178
Quote:
Originally Posted by suryaemlinux View Post
Hi folks,
I would like to read the start date and end date of the Daylight Saving Time for the given timezone in the given year. I'm using Linux 2.6.xx Kernel. What's the function in C/C++ to read the start of the Daylight Saving date and end of Daylight saving date?

For Example, in Pacific Time (US & Canada) the Daylight Start date for the year 2009 is Mar 9,2009 and it ended on Nov 1, 2009. I need a C/C++ function to read these dates.

Thanks in Advance,
Surya
Actually, in 2009 it was Sunday, Mar 8.

Anyway, there is no simple way to do this. As you may be aware, you need to be able to respond to legislative changes in the future. Although you can probably rely on your distribution to make changes in plenty of time, you may not want to rely on this.

I see three alternatives.

The first is simply to write a loop that uses mktime() and friends to loop through all the days of the year (pick a time like 6:00am) to see which are daylight savings time.

The second alternative is to see whether this can help you. I've never used it; I just went to sourceforge and searched.

The third alternative, the one I chose, is to follow this rather long yellow brick road. Then re-do it either periodically or whenever you hear of legislative changes:
  1. Code:
    mkdir tz # or whatever
    cd tz
    wget 'ftp://elsie.nci.nih.gov/pub/tz*.tar.gz'
    gzip -dc tzcode*.tar.gz | tar -xf -
    gzip -dc tzdata*.tar.gz | tar -xf -
  2. Within that directory, read these files:
    Code:
    README
    Theory
  3. Install the software. Or not, if you're content that the time zone information on your system is current. The reason to do the first two steps even if you don't want to install the software is so that you can read the Theory file. It's a treat. You'll even get information about telling time on Mars. If you don't install the software yourself, it's up to you to discover where your distribution places the compiled time zone information files. For example, in Slackware they're at /usr/share/zoneinfo
  4. Code:
    man -a tzfile
  5. Find the compiled time zone information file for the zone of interest.
  6. Cowboy up and write your code.
To get an idea of what's in these files, here's what my klugey program dumps for US/Pacific:
Code:
=== /usr/share/zoneinfo/US/Pacific
    ti_ttisgmtcnt is 4
    ti_ttisstdcnt is 4
    ti_leapcnt    is 0
    ti_timecnt    is 185
    ti_typecnt    is 4
    ti_charcnt    is 16
    === begin transitions
    0 9EA648A0 -1633269600 Sun 1918/03/31.10:00:00 UTC Sun 5/5 1918/03/31.03:00:00 -0700 (PDT)
    1 9FBB1590 -1615129200 Sun 1918/10/27.09:00:00 UTC Sun 4/4 1918/10/27.01:00:00 -0800 (PST)
    0 A0862AA0 -1601820000 Sun 1919/03/30.10:00:00 UTC Sun 5/5 1919/03/30.03:00:00 -0700 (PDT)
    1 A19AF790 -1583679600 Sun 1919/10/26.09:00:00 UTC Sun 4/4 1919/10/26.01:00:00 -0800 (PST)
    2 CB891AA0  -880207200 Mon 1942/02/09.10:00:00 UTC Mon 2/4 1942/02/09.03:00:00 -0700 (PWT)
    3 D223F470  -769395600 Tue 1945/08/14.23:00:00 UTC Tue 2/4 1945/08/14.16:00:00 -0700 (PPT)
    1 D2612610  -765385200 Sun 1945/09/30.09:00:00 UTC Sun 5/5 1945/09/30.01:00:00 -0800 (PST)
    0 D6FE7420  -687967200 Sun 1948/03/14.10:00:00 UTC Sun 2/4 1948/03/14.03:00:00 -0700 (PDT)
    1 D880AD90  -662655600 Sat 1949/01/01.09:00:00 UTC Sat 1/5 1949/01/01.01:00:00 -0800 (PST)
    0 DAFED1A0  -620834400 Sun 1950/04/30.10:00:00 UTC Sun 5/5 1950/04/30.03:00:00 -0700 (PDT)
    1 DBC09010  -608137200 Sun 1950/09/24.09:00:00 UTC Sun 4/4 1950/09/24.01:00:00 -0800 (PST)
    0 DCDEB3A0  -589384800 Sun 1951/04/29.10:00:00 UTC Sun 5/5 1951/04/29.03:00:00 -0700 (PDT)
    1 DDA9AC90  -576082800 Sun 1951/09/30.09:00:00 UTC Sun 5/5 1951/09/30.01:00:00 -0800 (PST)
    0 DEBE95A0  -557935200 Sun 1952/04/27.10:00:00 UTC Sun 4/4 1952/04/27.03:00:00 -0700 (PDT)
    1 DF898E90  -544633200 Sun 1952/09/28.09:00:00 UTC Sun 4/4 1952/09/28.01:00:00 -0800 (PST)
    0 E09E77A0  -526485600 Sun 1953/04/26.10:00:00 UTC Sun 4/4 1953/04/26.03:00:00 -0700 (PDT)
    1 E1697090  -513183600 Sun 1953/09/27.09:00:00 UTC Sun 4/4 1953/09/27.01:00:00 -0800 (PST)
    0 E27E59A0  -495036000 Sun 1954/04/25.10:00:00 UTC Sun 4/4 1954/04/25.03:00:00 -0700 (PDT)
    1 E3495290  -481734000 Sun 1954/09/26.09:00:00 UTC Sun 4/4 1954/09/26.01:00:00 -0800 (PST)
    0 E45E3BA0  -463586400 Sun 1955/04/24.10:00:00 UTC Sun 4/4 1955/04/24.03:00:00 -0700 (PDT)
    1 E5293490  -450284400 Sun 1955/09/25.09:00:00 UTC Sun 4/4 1955/09/25.01:00:00 -0800 (PST)
    0 E6475820  -431532000 Sun 1956/04/29.10:00:00 UTC Sun 5/5 1956/04/29.03:00:00 -0700 (PDT)
    1 E7125110  -418230000 Sun 1956/09/30.09:00:00 UTC Sun 5/5 1956/09/30.01:00:00 -0800 (PST)
    0 E8273A20  -400082400 Sun 1957/04/28.10:00:00 UTC Sun 4/4 1957/04/28.03:00:00 -0700 (PDT)
    1 E8F23310  -386780400 Sun 1957/09/29.09:00:00 UTC Sun 5/5 1957/09/29.01:00:00 -0800 (PST)
    0 EA071C20  -368632800 Sun 1958/04/27.10:00:00 UTC Sun 4/4 1958/04/27.03:00:00 -0700 (PDT)
    1 EAD21510  -355330800 Sun 1958/09/28.09:00:00 UTC Sun 4/4 1958/09/28.01:00:00 -0800 (PST)
    0 EBE6FE20  -337183200 Sun 1959/04/26.10:00:00 UTC Sun 4/4 1959/04/26.03:00:00 -0700 (PDT)
    1 ECB1F710  -323881200 Sun 1959/09/27.09:00:00 UTC Sun 4/4 1959/09/27.01:00:00 -0800 (PST)
    0 EDC6E020  -305733600 Sun 1960/04/24.10:00:00 UTC Sun 4/4 1960/04/24.03:00:00 -0700 (PDT)
    1 EE91D910  -292431600 Sun 1960/09/25.09:00:00 UTC Sun 4/4 1960/09/25.01:00:00 -0800 (PST)
    0 EFAFFCA0  -273679200 Sun 1961/04/30.10:00:00 UTC Sun 5/5 1961/04/30.03:00:00 -0700 (PDT)
    1 F071BB10  -260982000 Sun 1961/09/24.09:00:00 UTC Sun 4/4 1961/09/24.01:00:00 -0800 (PST)
    0 F18FDEA0  -242229600 Sun 1962/04/29.10:00:00 UTC Sun 5/5 1962/04/29.03:00:00 -0700 (PDT)
    1 F27FC190  -226508400 Sun 1962/10/28.09:00:00 UTC Sun 4/4 1962/10/28.01:00:00 -0800 (PST)
    0 F36FC0A0  -210780000 Sun 1963/04/28.10:00:00 UTC Sun 4/4 1963/04/28.03:00:00 -0700 (PDT)
    1 F45FA390  -195058800 Sun 1963/10/27.09:00:00 UTC Sun 4/4 1963/10/27.01:00:00 -0800 (PST)
    0 F54FA2A0  -179330400 Sun 1964/04/26.10:00:00 UTC Sun 4/4 1964/04/26.03:00:00 -0700 (PDT)
    1 F63F8590  -163609200 Sun 1964/10/25.09:00:00 UTC Sun 4/4 1964/10/25.01:00:00 -0800 (PST)
    0 F72F84A0  -147880800 Sun 1965/04/25.10:00:00 UTC Sun 4/4 1965/04/25.03:00:00 -0700 (PDT)
    1 F828A210  -131554800 Sun 1965/10/31.09:00:00 UTC Sun 5/5 1965/10/31.01:00:00 -0800 (PST)
    0 F90F66A0  -116431200 Sun 1966/04/24.10:00:00 UTC Sun 4/4 1966/04/24.03:00:00 -0700 (PDT)
    1 FA088410  -100105200 Sun 1966/10/30.09:00:00 UTC Sun 5/5 1966/10/30.01:00:00 -0800 (PST)
    0 FAF88320   -84376800 Sun 1967/04/30.10:00:00 UTC Sun 5/5 1967/04/30.03:00:00 -0700 (PDT)
    1 FBE86610   -68655600 Sun 1967/10/29.09:00:00 UTC Sun 5/5 1967/10/29.01:00:00 -0800 (PST)
    0 FCD86520   -52927200 Sun 1968/04/28.10:00:00 UTC Sun 4/4 1968/04/28.03:00:00 -0700 (PDT)
    1 FDC84810   -37206000 Sun 1968/10/27.09:00:00 UTC Sun 4/4 1968/10/27.01:00:00 -0800 (PST)
    0 FEB84720   -21477600 Sun 1969/04/27.10:00:00 UTC Sun 4/4 1969/04/27.03:00:00 -0700 (PDT)
    1 FFA82A10    -5756400 Sun 1969/10/26.09:00:00 UTC Sun 4/4 1969/10/26.01:00:00 -0800 (PST)
    0 00982920     9972000 Sun 1970/04/26.10:00:00 UTC Sun 4/4 1970/04/26.03:00:00 -0700 (PDT)
    1 01880C10    25693200 Sun 1970/10/25.09:00:00 UTC Sun 4/4 1970/10/25.01:00:00 -0800 (PST)
    0 02780B20    41421600 Sun 1971/04/25.10:00:00 UTC Sun 4/4 1971/04/25.03:00:00 -0700 (PDT)
    1 03712890    57747600 Sun 1971/10/31.09:00:00 UTC Sun 5/5 1971/10/31.01:00:00 -0800 (PST)
    0 046127A0    73476000 Sun 1972/04/30.10:00:00 UTC Sun 5/5 1972/04/30.03:00:00 -0700 (PDT)
    1 05510A90    89197200 Sun 1972/10/29.09:00:00 UTC Sun 5/5 1972/10/29.01:00:00 -0800 (PST)
    0 064109A0   104925600 Sun 1973/04/29.10:00:00 UTC Sun 5/5 1973/04/29.03:00:00 -0700 (PDT)
    1 0730EC90   120646800 Sun 1973/10/28.09:00:00 UTC Sun 4/4 1973/10/28.01:00:00 -0800 (PST)
    0 078D43A0   126698400 Sun 1974/01/06.10:00:00 UTC Sun 1/4 1974/01/06.03:00:00 -0700 (PDT)
    1 0910CE90   152096400 Sun 1974/10/27.09:00:00 UTC Sun 4/4 1974/10/27.01:00:00 -0800 (PST)
    0 09ADBF20   162381600 Sun 1975/02/23.10:00:00 UTC Sun 4/4 1975/02/23.03:00:00 -0700 (PDT)
    1 0AF0B090   183546000 Sun 1975/10/26.09:00:00 UTC Sun 4/4 1975/10/26.01:00:00 -0800 (PST)
    0 0BE0AFA0   199274400 Sun 1976/04/25.10:00:00 UTC Sun 4/4 1976/04/25.03:00:00 -0700 (PDT)
    1 0CD9CD10   215600400 Sun 1976/10/31.09:00:00 UTC Sun 5/5 1976/10/31.01:00:00 -0800 (PST)
    0 0DC091A0   230724000 Sun 1977/04/24.10:00:00 UTC Sun 4/4 1977/04/24.03:00:00 -0700 (PDT)
    1 0EB9AF10   247050000 Sun 1977/10/30.09:00:00 UTC Sun 5/5 1977/10/30.01:00:00 -0800 (PST)
    0 0FA9AE20   262778400 Sun 1978/04/30.10:00:00 UTC Sun 5/5 1978/04/30.03:00:00 -0700 (PDT)
    1 10999110   278499600 Sun 1978/10/29.09:00:00 UTC Sun 5/5 1978/10/29.01:00:00 -0800 (PST)
    0 11899020   294228000 Sun 1979/04/29.10:00:00 UTC Sun 5/5 1979/04/29.03:00:00 -0700 (PDT)
    1 12797310   309949200 Sun 1979/10/28.09:00:00 UTC Sun 4/4 1979/10/28.01:00:00 -0800 (PST)
    0 13697220   325677600 Sun 1980/04/27.10:00:00 UTC Sun 4/4 1980/04/27.03:00:00 -0700 (PDT)
    1 14595510   341398800 Sun 1980/10/26.09:00:00 UTC Sun 4/4 1980/10/26.01:00:00 -0800 (PST)
    0 15495420   357127200 Sun 1981/04/26.10:00:00 UTC Sun 4/4 1981/04/26.03:00:00 -0700 (PDT)
    1 16393710   372848400 Sun 1981/10/25.09:00:00 UTC Sun 4/4 1981/10/25.01:00:00 -0800 (PST)
    0 17293620   388576800 Sun 1982/04/25.10:00:00 UTC Sun 4/4 1982/04/25.03:00:00 -0700 (PDT)
    1 18225390   404902800 Sun 1982/10/31.09:00:00 UTC Sun 5/5 1982/10/31.01:00:00 -0800 (PST)
    0 19091820   420026400 Sun 1983/04/24.10:00:00 UTC Sun 4/4 1983/04/24.03:00:00 -0700 (PDT)
    1 1A023590   436352400 Sun 1983/10/30.09:00:00 UTC Sun 5/5 1983/10/30.01:00:00 -0800 (PST)
    0 1AF234A0   452080800 Sun 1984/04/29.10:00:00 UTC Sun 5/5 1984/04/29.03:00:00 -0700 (PDT)
    1 1BE21790   467802000 Sun 1984/10/28.09:00:00 UTC Sun 4/4 1984/10/28.01:00:00 -0800 (PST)
    0 1CD216A0   483530400 Sun 1985/04/28.10:00:00 UTC Sun 4/4 1985/04/28.03:00:00 -0700 (PDT)
    1 1DC1F990   499251600 Sun 1985/10/27.09:00:00 UTC Sun 4/4 1985/10/27.01:00:00 -0800 (PST)
    0 1EB1F8A0   514980000 Sun 1986/04/27.10:00:00 UTC Sun 4/4 1986/04/27.03:00:00 -0700 (PDT)
    1 1FA1DB90   530701200 Sun 1986/10/26.09:00:00 UTC Sun 4/4 1986/10/26.01:00:00 -0800 (PST)
    0 20762B20   544615200 Sun 1987/04/05.10:00:00 UTC Sun 1/4 1987/04/05.03:00:00 -0700 (PDT)
    1 2181BD90   562150800 Sun 1987/10/25.09:00:00 UTC Sun 4/4 1987/10/25.01:00:00 -0800 (PST)
    0 22560D20   576064800 Sun 1988/04/03.10:00:00 UTC Sun 1/4 1988/04/03.03:00:00 -0700 (PDT)
    1 236ADA10   594205200 Sun 1988/10/30.09:00:00 UTC Sun 5/5 1988/10/30.01:00:00 -0800 (PST)
    0 2435EF20   607514400 Sun 1989/04/02.10:00:00 UTC Sun 1/5 1989/04/02.03:00:00 -0700 (PDT)
    1 254ABC10   625654800 Sun 1989/10/29.09:00:00 UTC Sun 5/5 1989/10/29.01:00:00 -0800 (PST)
    0 2615D120   638964000 Sun 1990/04/01.10:00:00 UTC Sun 1/5 1990/04/01.03:00:00 -0700 (PDT)
    1 272A9E10   657104400 Sun 1990/10/28.09:00:00 UTC Sun 4/4 1990/10/28.01:00:00 -0800 (PST)
    0 27FEEDA0   671018400 Sun 1991/04/07.10:00:00 UTC Sun 1/4 1991/04/07.03:00:00 -0700 (PDT)
    1 290A8010   688554000 Sun 1991/10/27.09:00:00 UTC Sun 4/4 1991/10/27.01:00:00 -0800 (PST)
    0 29DECFA0   702468000 Sun 1992/04/05.10:00:00 UTC Sun 1/4 1992/04/05.03:00:00 -0700 (PDT)
    1 2AEA6210   720003600 Sun 1992/10/25.09:00:00 UTC Sun 4/4 1992/10/25.01:00:00 -0800 (PST)
    0 2BBEB1A0   733917600 Sun 1993/04/04.10:00:00 UTC Sun 1/4 1993/04/04.03:00:00 -0700 (PDT)
    1 2CD37E90   752058000 Sun 1993/10/31.09:00:00 UTC Sun 5/5 1993/10/31.01:00:00 -0800 (PST)
    0 2D9E93A0   765367200 Sun 1994/04/03.10:00:00 UTC Sun 1/4 1994/04/03.03:00:00 -0700 (PDT)
    1 2EB36090   783507600 Sun 1994/10/30.09:00:00 UTC Sun 5/5 1994/10/30.01:00:00 -0800 (PST)
    0 2F7E75A0   796816800 Sun 1995/04/02.10:00:00 UTC Sun 1/5 1995/04/02.03:00:00 -0700 (PDT)
    1 30934290   814957200 Sun 1995/10/29.09:00:00 UTC Sun 5/5 1995/10/29.01:00:00 -0800 (PST)
    0 31679220   828871200 Sun 1996/04/07.10:00:00 UTC Sun 1/4 1996/04/07.03:00:00 -0700 (PDT)
    1 32732490   846406800 Sun 1996/10/27.09:00:00 UTC Sun 4/4 1996/10/27.01:00:00 -0800 (PST)
    0 33477420   860320800 Sun 1997/04/06.10:00:00 UTC Sun 1/4 1997/04/06.03:00:00 -0700 (PDT)
    1 34530690   877856400 Sun 1997/10/26.09:00:00 UTC Sun 4/4 1997/10/26.01:00:00 -0800 (PST)
    0 35275620   891770400 Sun 1998/04/05.10:00:00 UTC Sun 1/4 1998/04/05.03:00:00 -0700 (PDT)
    1 3632E890   909306000 Sun 1998/10/25.09:00:00 UTC Sun 4/4 1998/10/25.01:00:00 -0800 (PST)
    0 37073820   923220000 Sun 1999/04/04.10:00:00 UTC Sun 1/4 1999/04/04.03:00:00 -0700 (PDT)
    1 381C0510   941360400 Sun 1999/10/31.09:00:00 UTC Sun 5/5 1999/10/31.01:00:00 -0800 (PST)
    0 38E71A20   954669600 Sun 2000/04/02.10:00:00 UTC Sun 1/5 2000/04/02.03:00:00 -0700 (PDT)
    1 39FBE710   972810000 Sun 2000/10/29.09:00:00 UTC Sun 5/5 2000/10/29.01:00:00 -0800 (PST)
    0 3AC6FC20   986119200 Sun 2001/04/01.10:00:00 UTC Sun 1/5 2001/04/01.03:00:00 -0700 (PDT)
    1 3BDBC910  1004259600 Sun 2001/10/28.09:00:00 UTC Sun 4/4 2001/10/28.01:00:00 -0800 (PST)
    0 3CB018A0  1018173600 Sun 2002/04/07.10:00:00 UTC Sun 1/4 2002/04/07.03:00:00 -0700 (PDT)
    1 3DBBAB10  1035709200 Sun 2002/10/27.09:00:00 UTC Sun 4/4 2002/10/27.01:00:00 -0800 (PST)
    0 3E8FFAA0  1049623200 Sun 2003/04/06.10:00:00 UTC Sun 1/4 2003/04/06.03:00:00 -0700 (PDT)
    1 3F9B8D10  1067158800 Sun 2003/10/26.09:00:00 UTC Sun 4/4 2003/10/26.01:00:00 -0800 (PST)
    0 406FDCA0  1081072800 Sun 2004/04/04.10:00:00 UTC Sun 1/4 2004/04/04.03:00:00 -0700 (PDT)
    1 4184A990  1099213200 Sun 2004/10/31.09:00:00 UTC Sun 5/5 2004/10/31.01:00:00 -0800 (PST)
    0 424FBEA0  1112522400 Sun 2005/04/03.10:00:00 UTC Sun 1/4 2005/04/03.03:00:00 -0700 (PDT)
    1 43648B90  1130662800 Sun 2005/10/30.09:00:00 UTC Sun 5/5 2005/10/30.01:00:00 -0800 (PST)
    0 442FA0A0  1143972000 Sun 2006/04/02.10:00:00 UTC Sun 1/5 2006/04/02.03:00:00 -0700 (PDT)
    1 45446D90  1162112400 Sun 2006/10/29.09:00:00 UTC Sun 5/5 2006/10/29.01:00:00 -0800 (PST)
    0 45F3D320  1173607200 Sun 2007/03/11.10:00:00 UTC Sun 2/4 2007/03/11.03:00:00 -0700 (PDT)
    1 472D8A10  1194166800 Sun 2007/11/04.09:00:00 UTC Sun 1/4 2007/11/04.01:00:00 -0800 (PST)
    0 47D3B520  1205056800 Sun 2008/03/09.10:00:00 UTC Sun 2/5 2008/03/09.03:00:00 -0700 (PDT)
    1 490D6C10  1225616400 Sun 2008/11/02.09:00:00 UTC Sun 1/5 2008/11/02.01:00:00 -0800 (PST)
    0 49B39720  1236506400 Sun 2009/03/08.10:00:00 UTC Sun 2/5 2009/03/08.03:00:00 -0700 (PDT)
    1 4AED4E10  1257066000 Sun 2009/11/01.09:00:00 UTC Sun 1/5 2009/11/01.01:00:00 -0800 (PST)
    0 4B9CB3A0  1268560800 Sun 2010/03/14.10:00:00 UTC Sun 2/4 2010/03/14.03:00:00 -0700 (PDT)
    1 4CD66A90  1289120400 Sun 2010/11/07.09:00:00 UTC Sun 1/4 2010/11/07.01:00:00 -0800 (PST)
    0 4D7C95A0  1300010400 Sun 2011/03/13.10:00:00 UTC Sun 2/4 2011/03/13.03:00:00 -0700 (PDT)
    1 4EB64C90  1320570000 Sun 2011/11/06.09:00:00 UTC Sun 1/4 2011/11/06.01:00:00 -0800 (PST)
    0 4F5C77A0  1331460000 Sun 2012/03/11.10:00:00 UTC Sun 2/4 2012/03/11.03:00:00 -0700 (PDT)
    1 50962E90  1352019600 Sun 2012/11/04.09:00:00 UTC Sun 1/4 2012/11/04.01:00:00 -0800 (PST)
    0 513C59A0  1362909600 Sun 2013/03/10.10:00:00 UTC Sun 2/5 2013/03/10.03:00:00 -0700 (PDT)
    1 52761090  1383469200 Sun 2013/11/03.09:00:00 UTC Sun 1/4 2013/11/03.01:00:00 -0800 (PST)
    0 531C3BA0  1394359200 Sun 2014/03/09.10:00:00 UTC Sun 2/5 2014/03/09.03:00:00 -0700 (PDT)
    1 5455F290  1414918800 Sun 2014/11/02.09:00:00 UTC Sun 1/5 2014/11/02.01:00:00 -0800 (PST)
    0 54FC1DA0  1425808800 Sun 2015/03/08.10:00:00 UTC Sun 2/5 2015/03/08.03:00:00 -0700 (PDT)
    1 5635D490  1446368400 Sun 2015/11/01.09:00:00 UTC Sun 1/5 2015/11/01.01:00:00 -0800 (PST)
    0 56E53A20  1457863200 Sun 2016/03/13.10:00:00 UTC Sun 2/4 2016/03/13.03:00:00 -0700 (PDT)
    1 581EF110  1478422800 Sun 2016/11/06.09:00:00 UTC Sun 1/4 2016/11/06.01:00:00 -0800 (PST)
    0 58C51C20  1489312800 Sun 2017/03/12.10:00:00 UTC Sun 2/4 2017/03/12.03:00:00 -0700 (PDT)
    1 59FED310  1509872400 Sun 2017/11/05.09:00:00 UTC Sun 1/4 2017/11/05.01:00:00 -0800 (PST)
    0 5AA4FE20  1520762400 Sun 2018/03/11.10:00:00 UTC Sun 2/4 2018/03/11.03:00:00 -0700 (PDT)
    1 5BDEB510  1541322000 Sun 2018/11/04.09:00:00 UTC Sun 1/4 2018/11/04.01:00:00 -0800 (PST)
    0 5C84E020  1552212000 Sun 2019/03/10.10:00:00 UTC Sun 2/5 2019/03/10.03:00:00 -0700 (PDT)
    1 5DBE9710  1572771600 Sun 2019/11/03.09:00:00 UTC Sun 1/4 2019/11/03.01:00:00 -0800 (PST)
    0 5E64C220  1583661600 Sun 2020/03/08.10:00:00 UTC Sun 2/5 2020/03/08.03:00:00 -0700 (PDT)
    1 5F9E7910  1604221200 Sun 2020/11/01.09:00:00 UTC Sun 1/5 2020/11/01.01:00:00 -0800 (PST)
    0 604DDEA0  1615716000 Sun 2021/03/14.10:00:00 UTC Sun 2/4 2021/03/14.03:00:00 -0700 (PDT)
    1 61879590  1636275600 Sun 2021/11/07.09:00:00 UTC Sun 1/4 2021/11/07.01:00:00 -0800 (PST)
    0 622DC0A0  1647165600 Sun 2022/03/13.10:00:00 UTC Sun 2/4 2022/03/13.03:00:00 -0700 (PDT)
    1 63677790  1667725200 Sun 2022/11/06.09:00:00 UTC Sun 1/4 2022/11/06.01:00:00 -0800 (PST)
    0 640DA2A0  1678615200 Sun 2023/03/12.10:00:00 UTC Sun 2/4 2023/03/12.03:00:00 -0700 (PDT)
    1 65475990  1699174800 Sun 2023/11/05.09:00:00 UTC Sun 1/4 2023/11/05.01:00:00 -0800 (PST)
    0 65ED84A0  1710064800 Sun 2024/03/10.10:00:00 UTC Sun 2/5 2024/03/10.03:00:00 -0700 (PDT)
    1 67273B90  1730624400 Sun 2024/11/03.09:00:00 UTC Sun 1/4 2024/11/03.01:00:00 -0800 (PST)
    0 67CD66A0  1741514400 Sun 2025/03/09.10:00:00 UTC Sun 2/5 2025/03/09.03:00:00 -0700 (PDT)
    1 69071D90  1762074000 Sun 2025/11/02.09:00:00 UTC Sun 1/5 2025/11/02.01:00:00 -0800 (PST)
    0 69AD48A0  1772964000 Sun 2026/03/08.10:00:00 UTC Sun 2/5 2026/03/08.03:00:00 -0700 (PDT)
    1 6AE6FF90  1793523600 Sun 2026/11/01.09:00:00 UTC Sun 1/5 2026/11/01.01:00:00 -0800 (PST)
    0 6B966520  1805018400 Sun 2027/03/14.10:00:00 UTC Sun 2/4 2027/03/14.03:00:00 -0700 (PDT)
    1 6CD01C10  1825578000 Sun 2027/11/07.09:00:00 UTC Sun 1/4 2027/11/07.01:00:00 -0800 (PST)
    0 6D764720  1836468000 Sun 2028/03/12.10:00:00 UTC Sun 2/4 2028/03/12.03:00:00 -0700 (PDT)
    1 6EAFFE10  1857027600 Sun 2028/11/05.09:00:00 UTC Sun 1/4 2028/11/05.01:00:00 -0800 (PST)
    0 6F562920  1867917600 Sun 2029/03/11.10:00:00 UTC Sun 2/4 2029/03/11.03:00:00 -0700 (PDT)
    1 708FE010  1888477200 Sun 2029/11/04.09:00:00 UTC Sun 1/4 2029/11/04.01:00:00 -0800 (PST)
    0 71360B20  1899367200 Sun 2030/03/10.10:00:00 UTC Sun 2/5 2030/03/10.03:00:00 -0700 (PDT)
    1 726FC210  1919926800 Sun 2030/11/03.09:00:00 UTC Sun 1/4 2030/11/03.01:00:00 -0800 (PST)
    0 7315ED20  1930816800 Sun 2031/03/09.10:00:00 UTC Sun 2/5 2031/03/09.03:00:00 -0700 (PDT)
    1 744FA410  1951376400 Sun 2031/11/02.09:00:00 UTC Sun 1/5 2031/11/02.01:00:00 -0800 (PST)
    0 74FF09A0  1962871200 Sun 2032/03/14.10:00:00 UTC Sun 2/4 2032/03/14.03:00:00 -0700 (PDT)
    1 7638C090  1983430800 Sun 2032/11/07.09:00:00 UTC Sun 1/4 2032/11/07.01:00:00 -0800 (PST)
    0 76DEEBA0  1994320800 Sun 2033/03/13.10:00:00 UTC Sun 2/4 2033/03/13.03:00:00 -0700 (PDT)
    1 7818A290  2014880400 Sun 2033/11/06.09:00:00 UTC Sun 1/4 2033/11/06.01:00:00 -0800 (PST)
    0 78BECDA0  2025770400 Sun 2034/03/12.10:00:00 UTC Sun 2/4 2034/03/12.03:00:00 -0700 (PDT)
    1 79F88490  2046330000 Sun 2034/11/05.09:00:00 UTC Sun 1/4 2034/11/05.01:00:00 -0800 (PST)
    0 7A9EAFA0  2057220000 Sun 2035/03/11.10:00:00 UTC Sun 2/4 2035/03/11.03:00:00 -0700 (PDT)
    1 7BD86690  2077779600 Sun 2035/11/04.09:00:00 UTC Sun 1/4 2035/11/04.01:00:00 -0800 (PST)
    0 7C7E91A0  2088669600 Sun 2036/03/09.10:00:00 UTC Sun 2/5 2036/03/09.03:00:00 -0700 (PDT)
    1 7DB84890  2109229200 Sun 2036/11/02.09:00:00 UTC Sun 1/5 2036/11/02.01:00:00 -0800 (PST)
    0 7E5E73A0  2120119200 Sun 2037/03/08.10:00:00 UTC Sun 2/5 2037/03/08.03:00:00 -0700 (PDT)
    1 7F982A90  2140678800 Sun 2037/11/01.09:00:00 UTC Sun 1/5 2037/11/01.01:00:00 -0800 (PST)
    === end   transitions
    === begin local time types
    + 0 0 -07:000:000 PDT
    - 0 0 -08:000:000 PST
    + 0 0 -07:000:000 PWT
    + 1 1 -07:000:000 PPT
    === end   local time types
    === begin leap second info
    === end   leap second info
Since the internally stored time of day in UNIXoid systems is measured as the number of non-leap seconds since 00:00, 1 Jan 1970 UTC, a common misconception is that this reference point is the earliest usable one. Not so. It can go negative, and does, as you can see in the above output.

Here are the differences between US/Pacific and Canada/Pacific.
Code:
1c1
< === /usr/share/zoneinfo/US/Pacific
---
> === /usr/share/zoneinfo/Canada/Pacific
5c5
<     ti_timecnt    is 185
---
>     ti_timecnt    is 189
9,12c9,10
<     0 9EA648A0 -1633269600 Sun 1918/03/31.10:00:00 UTC Sun 5/5 1918/03/31.03:00:00 -0700 (PDT)
<     1 9FBB1590 -1615129200 Sun 1918/10/27.09:00:00 UTC Sun 4/4 1918/10/27.01:00:00 -0800 (PST)
<     0 A0862AA0 -1601820000 Sun 1919/03/30.10:00:00 UTC Sun 5/5 1919/03/30.03:00:00 -0700 (PDT)
<     1 A19AF790 -1583679600 Sun 1919/10/26.09:00:00 UTC Sun 4/4 1919/10/26.01:00:00 -0800 (PST)
---
>     0 9EB8BDA0 -1632060000 Sun 1918/04/14.10:00:00 UTC Sun 2/4 1918/04/14.03:00:00 -0700 (PDT)
>     1 9FC05B90 -1614783600 Thu 1918/10/31.09:00:00 UTC Thu 5/5 1918/10/31.01:00:00 -0800 (PST)
16,17c14,21
<     0 D6FE7420  -687967200 Sun 1948/03/14.10:00:00 UTC Sun 2/4 1948/03/14.03:00:00 -0700 (PDT)
<     1 D880AD90  -662655600 Sat 1949/01/01.09:00:00 UTC Sat 1/5 1949/01/01.01:00:00 -0800 (PST)
---
>     0 D3760F20  -747237600 Sun 1946/04/28.10:00:00 UTC Sun 4/4 1946/04/28.03:00:00 -0700 (PDT)
>     1 D4537D10  -732726000 Sun 1946/10/13.09:00:00 UTC Sun 2/4 1946/10/13.01:00:00 -0800 (PST)
>     0 D555F120  -715788000 Sun 1947/04/27.10:00:00 UTC Sun 4/4 1947/04/27.03:00:00 -0700 (PDT)
>     1 D620EA10  -702486000 Sun 1947/09/28.09:00:00 UTC Sun 4/4 1947/09/28.01:00:00 -0800 (PST)
>     0 D735D320  -684338400 Sun 1948/04/25.10:00:00 UTC Sun 4/4 1948/04/25.03:00:00 -0700 (PDT)
>     1 D800CC10  -671036400 Sun 1948/09/26.09:00:00 UTC Sun 4/4 1948/09/26.01:00:00 -0800 (PST)
>     0 D915B520  -652888800 Sun 1949/04/24.10:00:00 UTC Sun 4/4 1949/04/24.03:00:00 -0700 (PDT)
>     1 D9E0AE10  -639586800 Sun 1949/09/25.09:00:00 UTC Sun 4/4 1949/09/25.01:00:00 -0800 (PST)
66c70
<     0 078D43A0   126698400 Sun 1974/01/06.10:00:00 UTC Sun 1/4 1974/01/06.03:00:00 -0700 (PDT)
---
>     0 0820EBA0   136375200 Sun 1974/04/28.10:00:00 UTC Sun 4/4 1974/04/28.03:00:00 -0700 (PDT)
68c72
<     0 09ADBF20   162381600 Sun 1975/02/23.10:00:00 UTC Sun 4/4 1975/02/23.03:00:00 -0700 (PDT)
---
>     0 0A00CDA0   167824800 Sun 1975/04/27.10:00:00 UTC Sun 4/4 1975/04/27.03:00:00 -0700 (PDT)
Hope this helps.
 
1 members found this post helpful.
Old 12-29-2009, 06:26 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 76
Also note that the only portable way to do this is looping each day with the POSIX time functions.

Some cross-platform toolkits might also provide interfaces for determining this information. For example KDE has KTimeZoneData. Glib and/or Qt might have their own interfaces.
 
1 members found this post helpful.
Old 12-29-2009, 08:17 PM   #4
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 178Reputation: 178
Quote:
Originally Posted by osor View Post
Also note that the only portable way to do this is looping each day with the POSIX time functions.
Very good point, if you're going for strict POSIX compatibility. For people running Linux, and for most people running UNIX, the yellow brick road gives you a deeper look at the theory.
 
Old 01-07-2010, 06:15 PM   #5
suryaemlinux
Member
 
Registered: Mar 2009
Distribution: CentOS, Fedora
Posts: 34

Original Poster
Rep: Reputation: 0
I was on a vacation. Will try your solution(s).Thanks for your help!!!

Quote:
Originally Posted by wje_lq View Post
Actually, in 2009 it was Sunday, Mar 8.

Anyway, there is no simple way to do this. As you may be aware, you need to be able to respond to legislative changes in the future. Although you can probably rely on your distribution to make changes in plenty of time, you may not want to rely on this.

I see three alternatives.

The first is simply to write a loop that uses mktime() and friends to loop through all the days of the year (pick a time like 6:00am) to see which are daylight savings time.

The second alternative is to see whether this can help you. I've never used it; I just went to sourceforge and searched.

The third alternative, the one I chose, is to follow this rather long yellow brick road. Then re-do it either periodically or whenever you hear of legislative changes:
  1. Code:
    mkdir tz # or whatever
    cd tz
    wget 'ftp://elsie.nci.nih.gov/pub/tz*.tar.gz'
    gzip -dc tzcode*.tar.gz | tar -xf -
    gzip -dc tzdata*.tar.gz | tar -xf -
  2. Within that directory, read these files:
    Code:
    README
    Theory
  3. Install the software. Or not, if you're content that the time zone information on your system is current. The reason to do the first two steps even if you don't want to install the software is so that you can read the Theory file. It's a treat. You'll even get information about telling time on Mars. If you don't install the software yourself, it's up to you to discover where your distribution places the compiled time zone information files. For example, in Slackware they're at /usr/share/zoneinfo
  4. Code:
    man -a tzfile
  5. Find the compiled time zone information file for the zone of interest.
  6. Cowboy up and write your code.
To get an idea of what's in these files, here's what my klugey program dumps for US/Pacific:
Code:
=== /usr/share/zoneinfo/US/Pacific
    ti_ttisgmtcnt is 4
    ti_ttisstdcnt is 4
    ti_leapcnt    is 0
    ti_timecnt    is 185
    ti_typecnt    is 4
    ti_charcnt    is 16
    === begin transitions
    0 9EA648A0 -1633269600 Sun 1918/03/31.10:00:00 UTC Sun 5/5 1918/03/31.03:00:00 -0700 (PDT)
    1 9FBB1590 -1615129200 Sun 1918/10/27.09:00:00 UTC Sun 4/4 1918/10/27.01:00:00 -0800 (PST)
    0 A0862AA0 -1601820000 Sun 1919/03/30.10:00:00 UTC Sun 5/5 1919/03/30.03:00:00 -0700 (PDT)
    1 A19AF790 -1583679600 Sun 1919/10/26.09:00:00 UTC Sun 4/4 1919/10/26.01:00:00 -0800 (PST)
    2 CB891AA0  -880207200 Mon 1942/02/09.10:00:00 UTC Mon 2/4 1942/02/09.03:00:00 -0700 (PWT)
    3 D223F470  -769395600 Tue 1945/08/14.23:00:00 UTC Tue 2/4 1945/08/14.16:00:00 -0700 (PPT)
    1 D2612610  -765385200 Sun 1945/09/30.09:00:00 UTC Sun 5/5 1945/09/30.01:00:00 -0800 (PST)
    0 D6FE7420  -687967200 Sun 1948/03/14.10:00:00 UTC Sun 2/4 1948/03/14.03:00:00 -0700 (PDT)
    1 D880AD90  -662655600 Sat 1949/01/01.09:00:00 UTC Sat 1/5 1949/01/01.01:00:00 -0800 (PST)
    0 DAFED1A0  -620834400 Sun 1950/04/30.10:00:00 UTC Sun 5/5 1950/04/30.03:00:00 -0700 (PDT)
    1 DBC09010  -608137200 Sun 1950/09/24.09:00:00 UTC Sun 4/4 1950/09/24.01:00:00 -0800 (PST)
    0 DCDEB3A0  -589384800 Sun 1951/04/29.10:00:00 UTC Sun 5/5 1951/04/29.03:00:00 -0700 (PDT)
    1 DDA9AC90  -576082800 Sun 1951/09/30.09:00:00 UTC Sun 5/5 1951/09/30.01:00:00 -0800 (PST)
    0 DEBE95A0  -557935200 Sun 1952/04/27.10:00:00 UTC Sun 4/4 1952/04/27.03:00:00 -0700 (PDT)
    1 DF898E90  -544633200 Sun 1952/09/28.09:00:00 UTC Sun 4/4 1952/09/28.01:00:00 -0800 (PST)
    0 E09E77A0  -526485600 Sun 1953/04/26.10:00:00 UTC Sun 4/4 1953/04/26.03:00:00 -0700 (PDT)
    1 E1697090  -513183600 Sun 1953/09/27.09:00:00 UTC Sun 4/4 1953/09/27.01:00:00 -0800 (PST)
    0 E27E59A0  -495036000 Sun 1954/04/25.10:00:00 UTC Sun 4/4 1954/04/25.03:00:00 -0700 (PDT)
    1 E3495290  -481734000 Sun 1954/09/26.09:00:00 UTC Sun 4/4 1954/09/26.01:00:00 -0800 (PST)
    0 E45E3BA0  -463586400 Sun 1955/04/24.10:00:00 UTC Sun 4/4 1955/04/24.03:00:00 -0700 (PDT)
    1 E5293490  -450284400 Sun 1955/09/25.09:00:00 UTC Sun 4/4 1955/09/25.01:00:00 -0800 (PST)
    0 E6475820  -431532000 Sun 1956/04/29.10:00:00 UTC Sun 5/5 1956/04/29.03:00:00 -0700 (PDT)
    1 E7125110  -418230000 Sun 1956/09/30.09:00:00 UTC Sun 5/5 1956/09/30.01:00:00 -0800 (PST)
    0 E8273A20  -400082400 Sun 1957/04/28.10:00:00 UTC Sun 4/4 1957/04/28.03:00:00 -0700 (PDT)
    1 E8F23310  -386780400 Sun 1957/09/29.09:00:00 UTC Sun 5/5 1957/09/29.01:00:00 -0800 (PST)
    0 EA071C20  -368632800 Sun 1958/04/27.10:00:00 UTC Sun 4/4 1958/04/27.03:00:00 -0700 (PDT)
    1 EAD21510  -355330800 Sun 1958/09/28.09:00:00 UTC Sun 4/4 1958/09/28.01:00:00 -0800 (PST)
    0 EBE6FE20  -337183200 Sun 1959/04/26.10:00:00 UTC Sun 4/4 1959/04/26.03:00:00 -0700 (PDT)
    1 ECB1F710  -323881200 Sun 1959/09/27.09:00:00 UTC Sun 4/4 1959/09/27.01:00:00 -0800 (PST)
    0 EDC6E020  -305733600 Sun 1960/04/24.10:00:00 UTC Sun 4/4 1960/04/24.03:00:00 -0700 (PDT)
    1 EE91D910  -292431600 Sun 1960/09/25.09:00:00 UTC Sun 4/4 1960/09/25.01:00:00 -0800 (PST)
    0 EFAFFCA0  -273679200 Sun 1961/04/30.10:00:00 UTC Sun 5/5 1961/04/30.03:00:00 -0700 (PDT)
    1 F071BB10  -260982000 Sun 1961/09/24.09:00:00 UTC Sun 4/4 1961/09/24.01:00:00 -0800 (PST)
    0 F18FDEA0  -242229600 Sun 1962/04/29.10:00:00 UTC Sun 5/5 1962/04/29.03:00:00 -0700 (PDT)
    1 F27FC190  -226508400 Sun 1962/10/28.09:00:00 UTC Sun 4/4 1962/10/28.01:00:00 -0800 (PST)
    0 F36FC0A0  -210780000 Sun 1963/04/28.10:00:00 UTC Sun 4/4 1963/04/28.03:00:00 -0700 (PDT)
    1 F45FA390  -195058800 Sun 1963/10/27.09:00:00 UTC Sun 4/4 1963/10/27.01:00:00 -0800 (PST)
    0 F54FA2A0  -179330400 Sun 1964/04/26.10:00:00 UTC Sun 4/4 1964/04/26.03:00:00 -0700 (PDT)
    1 F63F8590  -163609200 Sun 1964/10/25.09:00:00 UTC Sun 4/4 1964/10/25.01:00:00 -0800 (PST)
    0 F72F84A0  -147880800 Sun 1965/04/25.10:00:00 UTC Sun 4/4 1965/04/25.03:00:00 -0700 (PDT)
    1 F828A210  -131554800 Sun 1965/10/31.09:00:00 UTC Sun 5/5 1965/10/31.01:00:00 -0800 (PST)
    0 F90F66A0  -116431200 Sun 1966/04/24.10:00:00 UTC Sun 4/4 1966/04/24.03:00:00 -0700 (PDT)
    1 FA088410  -100105200 Sun 1966/10/30.09:00:00 UTC Sun 5/5 1966/10/30.01:00:00 -0800 (PST)
    0 FAF88320   -84376800 Sun 1967/04/30.10:00:00 UTC Sun 5/5 1967/04/30.03:00:00 -0700 (PDT)
    1 FBE86610   -68655600 Sun 1967/10/29.09:00:00 UTC Sun 5/5 1967/10/29.01:00:00 -0800 (PST)
    0 FCD86520   -52927200 Sun 1968/04/28.10:00:00 UTC Sun 4/4 1968/04/28.03:00:00 -0700 (PDT)
    1 FDC84810   -37206000 Sun 1968/10/27.09:00:00 UTC Sun 4/4 1968/10/27.01:00:00 -0800 (PST)
    0 FEB84720   -21477600 Sun 1969/04/27.10:00:00 UTC Sun 4/4 1969/04/27.03:00:00 -0700 (PDT)
    1 FFA82A10    -5756400 Sun 1969/10/26.09:00:00 UTC Sun 4/4 1969/10/26.01:00:00 -0800 (PST)
    0 00982920     9972000 Sun 1970/04/26.10:00:00 UTC Sun 4/4 1970/04/26.03:00:00 -0700 (PDT)
    1 01880C10    25693200 Sun 1970/10/25.09:00:00 UTC Sun 4/4 1970/10/25.01:00:00 -0800 (PST)
    0 02780B20    41421600 Sun 1971/04/25.10:00:00 UTC Sun 4/4 1971/04/25.03:00:00 -0700 (PDT)
    1 03712890    57747600 Sun 1971/10/31.09:00:00 UTC Sun 5/5 1971/10/31.01:00:00 -0800 (PST)
    0 046127A0    73476000 Sun 1972/04/30.10:00:00 UTC Sun 5/5 1972/04/30.03:00:00 -0700 (PDT)
    1 05510A90    89197200 Sun 1972/10/29.09:00:00 UTC Sun 5/5 1972/10/29.01:00:00 -0800 (PST)
    0 064109A0   104925600 Sun 1973/04/29.10:00:00 UTC Sun 5/5 1973/04/29.03:00:00 -0700 (PDT)
    1 0730EC90   120646800 Sun 1973/10/28.09:00:00 UTC Sun 4/4 1973/10/28.01:00:00 -0800 (PST)
    0 078D43A0   126698400 Sun 1974/01/06.10:00:00 UTC Sun 1/4 1974/01/06.03:00:00 -0700 (PDT)
    1 0910CE90   152096400 Sun 1974/10/27.09:00:00 UTC Sun 4/4 1974/10/27.01:00:00 -0800 (PST)
    0 09ADBF20   162381600 Sun 1975/02/23.10:00:00 UTC Sun 4/4 1975/02/23.03:00:00 -0700 (PDT)
    1 0AF0B090   183546000 Sun 1975/10/26.09:00:00 UTC Sun 4/4 1975/10/26.01:00:00 -0800 (PST)
    0 0BE0AFA0   199274400 Sun 1976/04/25.10:00:00 UTC Sun 4/4 1976/04/25.03:00:00 -0700 (PDT)
    1 0CD9CD10   215600400 Sun 1976/10/31.09:00:00 UTC Sun 5/5 1976/10/31.01:00:00 -0800 (PST)
    0 0DC091A0   230724000 Sun 1977/04/24.10:00:00 UTC Sun 4/4 1977/04/24.03:00:00 -0700 (PDT)
    1 0EB9AF10   247050000 Sun 1977/10/30.09:00:00 UTC Sun 5/5 1977/10/30.01:00:00 -0800 (PST)
    0 0FA9AE20   262778400 Sun 1978/04/30.10:00:00 UTC Sun 5/5 1978/04/30.03:00:00 -0700 (PDT)
    1 10999110   278499600 Sun 1978/10/29.09:00:00 UTC Sun 5/5 1978/10/29.01:00:00 -0800 (PST)
    0 11899020   294228000 Sun 1979/04/29.10:00:00 UTC Sun 5/5 1979/04/29.03:00:00 -0700 (PDT)
    1 12797310   309949200 Sun 1979/10/28.09:00:00 UTC Sun 4/4 1979/10/28.01:00:00 -0800 (PST)
    0 13697220   325677600 Sun 1980/04/27.10:00:00 UTC Sun 4/4 1980/04/27.03:00:00 -0700 (PDT)
    1 14595510   341398800 Sun 1980/10/26.09:00:00 UTC Sun 4/4 1980/10/26.01:00:00 -0800 (PST)
    0 15495420   357127200 Sun 1981/04/26.10:00:00 UTC Sun 4/4 1981/04/26.03:00:00 -0700 (PDT)
    1 16393710   372848400 Sun 1981/10/25.09:00:00 UTC Sun 4/4 1981/10/25.01:00:00 -0800 (PST)
    0 17293620   388576800 Sun 1982/04/25.10:00:00 UTC Sun 4/4 1982/04/25.03:00:00 -0700 (PDT)
    1 18225390   404902800 Sun 1982/10/31.09:00:00 UTC Sun 5/5 1982/10/31.01:00:00 -0800 (PST)
    0 19091820   420026400 Sun 1983/04/24.10:00:00 UTC Sun 4/4 1983/04/24.03:00:00 -0700 (PDT)
    1 1A023590   436352400 Sun 1983/10/30.09:00:00 UTC Sun 5/5 1983/10/30.01:00:00 -0800 (PST)
    0 1AF234A0   452080800 Sun 1984/04/29.10:00:00 UTC Sun 5/5 1984/04/29.03:00:00 -0700 (PDT)
    1 1BE21790   467802000 Sun 1984/10/28.09:00:00 UTC Sun 4/4 1984/10/28.01:00:00 -0800 (PST)
    0 1CD216A0   483530400 Sun 1985/04/28.10:00:00 UTC Sun 4/4 1985/04/28.03:00:00 -0700 (PDT)
    1 1DC1F990   499251600 Sun 1985/10/27.09:00:00 UTC Sun 4/4 1985/10/27.01:00:00 -0800 (PST)
    0 1EB1F8A0   514980000 Sun 1986/04/27.10:00:00 UTC Sun 4/4 1986/04/27.03:00:00 -0700 (PDT)
    1 1FA1DB90   530701200 Sun 1986/10/26.09:00:00 UTC Sun 4/4 1986/10/26.01:00:00 -0800 (PST)
    0 20762B20   544615200 Sun 1987/04/05.10:00:00 UTC Sun 1/4 1987/04/05.03:00:00 -0700 (PDT)
    1 2181BD90   562150800 Sun 1987/10/25.09:00:00 UTC Sun 4/4 1987/10/25.01:00:00 -0800 (PST)
    0 22560D20   576064800 Sun 1988/04/03.10:00:00 UTC Sun 1/4 1988/04/03.03:00:00 -0700 (PDT)
    1 236ADA10   594205200 Sun 1988/10/30.09:00:00 UTC Sun 5/5 1988/10/30.01:00:00 -0800 (PST)
    0 2435EF20   607514400 Sun 1989/04/02.10:00:00 UTC Sun 1/5 1989/04/02.03:00:00 -0700 (PDT)
    1 254ABC10   625654800 Sun 1989/10/29.09:00:00 UTC Sun 5/5 1989/10/29.01:00:00 -0800 (PST)
    0 2615D120   638964000 Sun 1990/04/01.10:00:00 UTC Sun 1/5 1990/04/01.03:00:00 -0700 (PDT)
    1 272A9E10   657104400 Sun 1990/10/28.09:00:00 UTC Sun 4/4 1990/10/28.01:00:00 -0800 (PST)
    0 27FEEDA0   671018400 Sun 1991/04/07.10:00:00 UTC Sun 1/4 1991/04/07.03:00:00 -0700 (PDT)
    1 290A8010   688554000 Sun 1991/10/27.09:00:00 UTC Sun 4/4 1991/10/27.01:00:00 -0800 (PST)
    0 29DECFA0   702468000 Sun 1992/04/05.10:00:00 UTC Sun 1/4 1992/04/05.03:00:00 -0700 (PDT)
    1 2AEA6210   720003600 Sun 1992/10/25.09:00:00 UTC Sun 4/4 1992/10/25.01:00:00 -0800 (PST)
    0 2BBEB1A0   733917600 Sun 1993/04/04.10:00:00 UTC Sun 1/4 1993/04/04.03:00:00 -0700 (PDT)
    1 2CD37E90   752058000 Sun 1993/10/31.09:00:00 UTC Sun 5/5 1993/10/31.01:00:00 -0800 (PST)
    0 2D9E93A0   765367200 Sun 1994/04/03.10:00:00 UTC Sun 1/4 1994/04/03.03:00:00 -0700 (PDT)
    1 2EB36090   783507600 Sun 1994/10/30.09:00:00 UTC Sun 5/5 1994/10/30.01:00:00 -0800 (PST)
    0 2F7E75A0   796816800 Sun 1995/04/02.10:00:00 UTC Sun 1/5 1995/04/02.03:00:00 -0700 (PDT)
    1 30934290   814957200 Sun 1995/10/29.09:00:00 UTC Sun 5/5 1995/10/29.01:00:00 -0800 (PST)
    0 31679220   828871200 Sun 1996/04/07.10:00:00 UTC Sun 1/4 1996/04/07.03:00:00 -0700 (PDT)
    1 32732490   846406800 Sun 1996/10/27.09:00:00 UTC Sun 4/4 1996/10/27.01:00:00 -0800 (PST)
    0 33477420   860320800 Sun 1997/04/06.10:00:00 UTC Sun 1/4 1997/04/06.03:00:00 -0700 (PDT)
    1 34530690   877856400 Sun 1997/10/26.09:00:00 UTC Sun 4/4 1997/10/26.01:00:00 -0800 (PST)
    0 35275620   891770400 Sun 1998/04/05.10:00:00 UTC Sun 1/4 1998/04/05.03:00:00 -0700 (PDT)
    1 3632E890   909306000 Sun 1998/10/25.09:00:00 UTC Sun 4/4 1998/10/25.01:00:00 -0800 (PST)
    0 37073820   923220000 Sun 1999/04/04.10:00:00 UTC Sun 1/4 1999/04/04.03:00:00 -0700 (PDT)
    1 381C0510   941360400 Sun 1999/10/31.09:00:00 UTC Sun 5/5 1999/10/31.01:00:00 -0800 (PST)
    0 38E71A20   954669600 Sun 2000/04/02.10:00:00 UTC Sun 1/5 2000/04/02.03:00:00 -0700 (PDT)
    1 39FBE710   972810000 Sun 2000/10/29.09:00:00 UTC Sun 5/5 2000/10/29.01:00:00 -0800 (PST)
    0 3AC6FC20   986119200 Sun 2001/04/01.10:00:00 UTC Sun 1/5 2001/04/01.03:00:00 -0700 (PDT)
    1 3BDBC910  1004259600 Sun 2001/10/28.09:00:00 UTC Sun 4/4 2001/10/28.01:00:00 -0800 (PST)
    0 3CB018A0  1018173600 Sun 2002/04/07.10:00:00 UTC Sun 1/4 2002/04/07.03:00:00 -0700 (PDT)
    1 3DBBAB10  1035709200 Sun 2002/10/27.09:00:00 UTC Sun 4/4 2002/10/27.01:00:00 -0800 (PST)
    0 3E8FFAA0  1049623200 Sun 2003/04/06.10:00:00 UTC Sun 1/4 2003/04/06.03:00:00 -0700 (PDT)
    1 3F9B8D10  1067158800 Sun 2003/10/26.09:00:00 UTC Sun 4/4 2003/10/26.01:00:00 -0800 (PST)
    0 406FDCA0  1081072800 Sun 2004/04/04.10:00:00 UTC Sun 1/4 2004/04/04.03:00:00 -0700 (PDT)
    1 4184A990  1099213200 Sun 2004/10/31.09:00:00 UTC Sun 5/5 2004/10/31.01:00:00 -0800 (PST)
    0 424FBEA0  1112522400 Sun 2005/04/03.10:00:00 UTC Sun 1/4 2005/04/03.03:00:00 -0700 (PDT)
    1 43648B90  1130662800 Sun 2005/10/30.09:00:00 UTC Sun 5/5 2005/10/30.01:00:00 -0800 (PST)
    0 442FA0A0  1143972000 Sun 2006/04/02.10:00:00 UTC Sun 1/5 2006/04/02.03:00:00 -0700 (PDT)
    1 45446D90  1162112400 Sun 2006/10/29.09:00:00 UTC Sun 5/5 2006/10/29.01:00:00 -0800 (PST)
    0 45F3D320  1173607200 Sun 2007/03/11.10:00:00 UTC Sun 2/4 2007/03/11.03:00:00 -0700 (PDT)
    1 472D8A10  1194166800 Sun 2007/11/04.09:00:00 UTC Sun 1/4 2007/11/04.01:00:00 -0800 (PST)
    0 47D3B520  1205056800 Sun 2008/03/09.10:00:00 UTC Sun 2/5 2008/03/09.03:00:00 -0700 (PDT)
    1 490D6C10  1225616400 Sun 2008/11/02.09:00:00 UTC Sun 1/5 2008/11/02.01:00:00 -0800 (PST)
    0 49B39720  1236506400 Sun 2009/03/08.10:00:00 UTC Sun 2/5 2009/03/08.03:00:00 -0700 (PDT)
    1 4AED4E10  1257066000 Sun 2009/11/01.09:00:00 UTC Sun 1/5 2009/11/01.01:00:00 -0800 (PST)
    0 4B9CB3A0  1268560800 Sun 2010/03/14.10:00:00 UTC Sun 2/4 2010/03/14.03:00:00 -0700 (PDT)
    1 4CD66A90  1289120400 Sun 2010/11/07.09:00:00 UTC Sun 1/4 2010/11/07.01:00:00 -0800 (PST)
    0 4D7C95A0  1300010400 Sun 2011/03/13.10:00:00 UTC Sun 2/4 2011/03/13.03:00:00 -0700 (PDT)
    1 4EB64C90  1320570000 Sun 2011/11/06.09:00:00 UTC Sun 1/4 2011/11/06.01:00:00 -0800 (PST)
    0 4F5C77A0  1331460000 Sun 2012/03/11.10:00:00 UTC Sun 2/4 2012/03/11.03:00:00 -0700 (PDT)
    1 50962E90  1352019600 Sun 2012/11/04.09:00:00 UTC Sun 1/4 2012/11/04.01:00:00 -0800 (PST)
    0 513C59A0  1362909600 Sun 2013/03/10.10:00:00 UTC Sun 2/5 2013/03/10.03:00:00 -0700 (PDT)
    1 52761090  1383469200 Sun 2013/11/03.09:00:00 UTC Sun 1/4 2013/11/03.01:00:00 -0800 (PST)
    0 531C3BA0  1394359200 Sun 2014/03/09.10:00:00 UTC Sun 2/5 2014/03/09.03:00:00 -0700 (PDT)
    1 5455F290  1414918800 Sun 2014/11/02.09:00:00 UTC Sun 1/5 2014/11/02.01:00:00 -0800 (PST)
    0 54FC1DA0  1425808800 Sun 2015/03/08.10:00:00 UTC Sun 2/5 2015/03/08.03:00:00 -0700 (PDT)
    1 5635D490  1446368400 Sun 2015/11/01.09:00:00 UTC Sun 1/5 2015/11/01.01:00:00 -0800 (PST)
    0 56E53A20  1457863200 Sun 2016/03/13.10:00:00 UTC Sun 2/4 2016/03/13.03:00:00 -0700 (PDT)
    1 581EF110  1478422800 Sun 2016/11/06.09:00:00 UTC Sun 1/4 2016/11/06.01:00:00 -0800 (PST)
    0 58C51C20  1489312800 Sun 2017/03/12.10:00:00 UTC Sun 2/4 2017/03/12.03:00:00 -0700 (PDT)
    1 59FED310  1509872400 Sun 2017/11/05.09:00:00 UTC Sun 1/4 2017/11/05.01:00:00 -0800 (PST)
    0 5AA4FE20  1520762400 Sun 2018/03/11.10:00:00 UTC Sun 2/4 2018/03/11.03:00:00 -0700 (PDT)
    1 5BDEB510  1541322000 Sun 2018/11/04.09:00:00 UTC Sun 1/4 2018/11/04.01:00:00 -0800 (PST)
    0 5C84E020  1552212000 Sun 2019/03/10.10:00:00 UTC Sun 2/5 2019/03/10.03:00:00 -0700 (PDT)
    1 5DBE9710  1572771600 Sun 2019/11/03.09:00:00 UTC Sun 1/4 2019/11/03.01:00:00 -0800 (PST)
    0 5E64C220  1583661600 Sun 2020/03/08.10:00:00 UTC Sun 2/5 2020/03/08.03:00:00 -0700 (PDT)
    1 5F9E7910  1604221200 Sun 2020/11/01.09:00:00 UTC Sun 1/5 2020/11/01.01:00:00 -0800 (PST)
    0 604DDEA0  1615716000 Sun 2021/03/14.10:00:00 UTC Sun 2/4 2021/03/14.03:00:00 -0700 (PDT)
    1 61879590  1636275600 Sun 2021/11/07.09:00:00 UTC Sun 1/4 2021/11/07.01:00:00 -0800 (PST)
    0 622DC0A0  1647165600 Sun 2022/03/13.10:00:00 UTC Sun 2/4 2022/03/13.03:00:00 -0700 (PDT)
    1 63677790  1667725200 Sun 2022/11/06.09:00:00 UTC Sun 1/4 2022/11/06.01:00:00 -0800 (PST)
    0 640DA2A0  1678615200 Sun 2023/03/12.10:00:00 UTC Sun 2/4 2023/03/12.03:00:00 -0700 (PDT)
    1 65475990  1699174800 Sun 2023/11/05.09:00:00 UTC Sun 1/4 2023/11/05.01:00:00 -0800 (PST)
    0 65ED84A0  1710064800 Sun 2024/03/10.10:00:00 UTC Sun 2/5 2024/03/10.03:00:00 -0700 (PDT)
    1 67273B90  1730624400 Sun 2024/11/03.09:00:00 UTC Sun 1/4 2024/11/03.01:00:00 -0800 (PST)
    0 67CD66A0  1741514400 Sun 2025/03/09.10:00:00 UTC Sun 2/5 2025/03/09.03:00:00 -0700 (PDT)
    1 69071D90  1762074000 Sun 2025/11/02.09:00:00 UTC Sun 1/5 2025/11/02.01:00:00 -0800 (PST)
    0 69AD48A0  1772964000 Sun 2026/03/08.10:00:00 UTC Sun 2/5 2026/03/08.03:00:00 -0700 (PDT)
    1 6AE6FF90  1793523600 Sun 2026/11/01.09:00:00 UTC Sun 1/5 2026/11/01.01:00:00 -0800 (PST)
    0 6B966520  1805018400 Sun 2027/03/14.10:00:00 UTC Sun 2/4 2027/03/14.03:00:00 -0700 (PDT)
    1 6CD01C10  1825578000 Sun 2027/11/07.09:00:00 UTC Sun 1/4 2027/11/07.01:00:00 -0800 (PST)
    0 6D764720  1836468000 Sun 2028/03/12.10:00:00 UTC Sun 2/4 2028/03/12.03:00:00 -0700 (PDT)
    1 6EAFFE10  1857027600 Sun 2028/11/05.09:00:00 UTC Sun 1/4 2028/11/05.01:00:00 -0800 (PST)
    0 6F562920  1867917600 Sun 2029/03/11.10:00:00 UTC Sun 2/4 2029/03/11.03:00:00 -0700 (PDT)
    1 708FE010  1888477200 Sun 2029/11/04.09:00:00 UTC Sun 1/4 2029/11/04.01:00:00 -0800 (PST)
    0 71360B20  1899367200 Sun 2030/03/10.10:00:00 UTC Sun 2/5 2030/03/10.03:00:00 -0700 (PDT)
    1 726FC210  1919926800 Sun 2030/11/03.09:00:00 UTC Sun 1/4 2030/11/03.01:00:00 -0800 (PST)
    0 7315ED20  1930816800 Sun 2031/03/09.10:00:00 UTC Sun 2/5 2031/03/09.03:00:00 -0700 (PDT)
    1 744FA410  1951376400 Sun 2031/11/02.09:00:00 UTC Sun 1/5 2031/11/02.01:00:00 -0800 (PST)
    0 74FF09A0  1962871200 Sun 2032/03/14.10:00:00 UTC Sun 2/4 2032/03/14.03:00:00 -0700 (PDT)
    1 7638C090  1983430800 Sun 2032/11/07.09:00:00 UTC Sun 1/4 2032/11/07.01:00:00 -0800 (PST)
    0 76DEEBA0  1994320800 Sun 2033/03/13.10:00:00 UTC Sun 2/4 2033/03/13.03:00:00 -0700 (PDT)
    1 7818A290  2014880400 Sun 2033/11/06.09:00:00 UTC Sun 1/4 2033/11/06.01:00:00 -0800 (PST)
    0 78BECDA0  2025770400 Sun 2034/03/12.10:00:00 UTC Sun 2/4 2034/03/12.03:00:00 -0700 (PDT)
    1 79F88490  2046330000 Sun 2034/11/05.09:00:00 UTC Sun 1/4 2034/11/05.01:00:00 -0800 (PST)
    0 7A9EAFA0  2057220000 Sun 2035/03/11.10:00:00 UTC Sun 2/4 2035/03/11.03:00:00 -0700 (PDT)
    1 7BD86690  2077779600 Sun 2035/11/04.09:00:00 UTC Sun 1/4 2035/11/04.01:00:00 -0800 (PST)
    0 7C7E91A0  2088669600 Sun 2036/03/09.10:00:00 UTC Sun 2/5 2036/03/09.03:00:00 -0700 (PDT)
    1 7DB84890  2109229200 Sun 2036/11/02.09:00:00 UTC Sun 1/5 2036/11/02.01:00:00 -0800 (PST)
    0 7E5E73A0  2120119200 Sun 2037/03/08.10:00:00 UTC Sun 2/5 2037/03/08.03:00:00 -0700 (PDT)
    1 7F982A90  2140678800 Sun 2037/11/01.09:00:00 UTC Sun 1/5 2037/11/01.01:00:00 -0800 (PST)
    === end   transitions
    === begin local time types
    + 0 0 -07:000:000 PDT
    - 0 0 -08:000:000 PST
    + 0 0 -07:000:000 PWT
    + 1 1 -07:000:000 PPT
    === end   local time types
    === begin leap second info
    === end   leap second info
Since the internally stored time of day in UNIXoid systems is measured as the number of non-leap seconds since 00:00, 1 Jan 1970 UTC, a common misconception is that this reference point is the earliest usable one. Not so. It can go negative, and does, as you can see in the above output.

Here are the differences between US/Pacific and Canada/Pacific.
Code:
1c1
< === /usr/share/zoneinfo/US/Pacific
---
> === /usr/share/zoneinfo/Canada/Pacific
5c5
<     ti_timecnt    is 185
---
>     ti_timecnt    is 189
9,12c9,10
<     0 9EA648A0 -1633269600 Sun 1918/03/31.10:00:00 UTC Sun 5/5 1918/03/31.03:00:00 -0700 (PDT)
<     1 9FBB1590 -1615129200 Sun 1918/10/27.09:00:00 UTC Sun 4/4 1918/10/27.01:00:00 -0800 (PST)
<     0 A0862AA0 -1601820000 Sun 1919/03/30.10:00:00 UTC Sun 5/5 1919/03/30.03:00:00 -0700 (PDT)
<     1 A19AF790 -1583679600 Sun 1919/10/26.09:00:00 UTC Sun 4/4 1919/10/26.01:00:00 -0800 (PST)
---
>     0 9EB8BDA0 -1632060000 Sun 1918/04/14.10:00:00 UTC Sun 2/4 1918/04/14.03:00:00 -0700 (PDT)
>     1 9FC05B90 -1614783600 Thu 1918/10/31.09:00:00 UTC Thu 5/5 1918/10/31.01:00:00 -0800 (PST)
16,17c14,21
<     0 D6FE7420  -687967200 Sun 1948/03/14.10:00:00 UTC Sun 2/4 1948/03/14.03:00:00 -0700 (PDT)
<     1 D880AD90  -662655600 Sat 1949/01/01.09:00:00 UTC Sat 1/5 1949/01/01.01:00:00 -0800 (PST)
---
>     0 D3760F20  -747237600 Sun 1946/04/28.10:00:00 UTC Sun 4/4 1946/04/28.03:00:00 -0700 (PDT)
>     1 D4537D10  -732726000 Sun 1946/10/13.09:00:00 UTC Sun 2/4 1946/10/13.01:00:00 -0800 (PST)
>     0 D555F120  -715788000 Sun 1947/04/27.10:00:00 UTC Sun 4/4 1947/04/27.03:00:00 -0700 (PDT)
>     1 D620EA10  -702486000 Sun 1947/09/28.09:00:00 UTC Sun 4/4 1947/09/28.01:00:00 -0800 (PST)
>     0 D735D320  -684338400 Sun 1948/04/25.10:00:00 UTC Sun 4/4 1948/04/25.03:00:00 -0700 (PDT)
>     1 D800CC10  -671036400 Sun 1948/09/26.09:00:00 UTC Sun 4/4 1948/09/26.01:00:00 -0800 (PST)
>     0 D915B520  -652888800 Sun 1949/04/24.10:00:00 UTC Sun 4/4 1949/04/24.03:00:00 -0700 (PDT)
>     1 D9E0AE10  -639586800 Sun 1949/09/25.09:00:00 UTC Sun 4/4 1949/09/25.01:00:00 -0800 (PST)
66c70
<     0 078D43A0   126698400 Sun 1974/01/06.10:00:00 UTC Sun 1/4 1974/01/06.03:00:00 -0700 (PDT)
---
>     0 0820EBA0   136375200 Sun 1974/04/28.10:00:00 UTC Sun 4/4 1974/04/28.03:00:00 -0700 (PDT)
68c72
<     0 09ADBF20   162381600 Sun 1975/02/23.10:00:00 UTC Sun 4/4 1975/02/23.03:00:00 -0700 (PDT)
---
>     0 0A00CDA0   167824800 Sun 1975/04/27.10:00:00 UTC Sun 4/4 1975/04/27.03:00:00 -0700 (PDT)
Hope this helps.
 
Old 01-12-2010, 07:48 PM   #6
suryaemlinux
Member
 
Registered: Mar 2009
Distribution: CentOS, Fedora
Posts: 34

Original Poster
Rep: Reputation: 0
Hi wje_lq,
I tried reading the "/usr/share/zoneinfo/America/Los_Angeles" file in my linux distribution. I treated this as a binary file to read but I couldn't get anything out of it. Only some characters here and there. How did you process the zoneinfo file which you had given in the earlier post.

Thanks for your help!!
Surya
 
Old 01-13-2010, 04:13 AM   #7
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 178Reputation: 178
To make sense of a time zone info file, do this at the command line:
Code:
man tzfile
Please note that the man page says that the integers are written big-endian, and most of us have hardware which stores binary integers little-endian. So you'll need to reverse the order of the bytes in each integer you read.

To help you write your code to process this file, here's a hex dump of the current content of America/Los_Angeles:
Code:
0000  545A 6966 3200 0000  0000 0000 0000 0000  *TZif2...........*
0010  0000 0000 0000 0004  0000 0004 0000 0000  *................*
0020  0000 00B9 0000 0004  0000 0010 9EA6 48A0  *..............H.*
0030  9FBB 1590 A086 2AA0  A19A F790 CB89 1AA0  *......*.........*
0040  D223 F470 D261 2610  D6FE 7420 D880 AD90  *.#.p.a&...t ....*
0050  DAFE D1A0 DBC0 9010  DCDE B3A0 DDA9 AC90  *................*
0060  DEBE 95A0 DF89 8E90  E09E 77A0 E169 7090  *..........w..ip.*
0070  E27E 59A0 E349 5290  E45E 3BA0 E529 3490  *.~Y..IR..^;..)4.*
0080  E647 5820 E712 5110  E827 3A20 E8F2 3310  *.GX ..Q..': ..3.*
0090  EA07 1C20 EAD2 1510  EBE6 FE20 ECB1 F710  *... ....... ....*
00A0  EDC6 E020 EE91 D910  EFAF FCA0 F071 BB10  *... .........q..*
00B0  F18F DEA0 F27F C190  F36F C0A0 F45F A390  *.........o..._..*
00C0  F54F A2A0 F63F 8590  F72F 84A0 F828 A210  *.O...?.../...(..*
00D0  F90F 66A0 FA08 8410  FAF8 8320 FBE8 6610  *..f........ ..f.*
00E0  FCD8 6520 FDC8 4810  FEB8 4720 FFA8 2A10  *..e ..H...G ..*.*
00F0  0098 2920 0188 0C10  0278 0B20 0371 2890  *..) .....x. .q(.*
0100  0461 27A0 0551 0A90  0641 09A0 0730 EC90  *.a'..Q...A...0..*
0110  078D 43A0 0910 CE90  09AD BF20 0AF0 B090  *..C........ ....*
0120  0BE0 AFA0 0CD9 CD10  0DC0 91A0 0EB9 AF10  *................*
0130  0FA9 AE20 1099 9110  1189 9020 1279 7310  *... ....... .ys.*
0140  1369 7220 1459 5510  1549 5420 1639 3710  *.ir .YU..IT .97.*
0150  1729 3620 1822 5390  1909 1820 1A02 3590  *.)6 ."S.... ..5.*
0160  1AF2 34A0 1BE2 1790  1CD2 16A0 1DC1 F990  *..4.............*
0170  1EB1 F8A0 1FA1 DB90  2076 2B20 2181 BD90  *........ v+ !...*
0180  2256 0D20 236A DA10  2435 EF20 254A BC10  *"V. #j..$5. %J..*
0190  2615 D120 272A 9E10  27FE EDA0 290A 8010  *&.. '*..'...)...*
01A0  29DE CFA0 2AEA 6210  2BBE B1A0 2CD3 7E90  *)...*.b.+...,.~.*
01B0  2D9E 93A0 2EB3 6090  2F7E 75A0 3093 4290  *-.....`./~u.0.B.*
01C0  3167 9220 3273 2490  3347 7420 3453 0690  *1g. 2s$.3Gt 4S..*
01D0  3527 5620 3632 E890  3707 3820 381C 0510  *5'V 62..7.8 8...*
01E0  38E7 1A20 39FB E710  3AC6 FC20 3BDB C910  *8.. 9...:.. ;...*
01F0  3CB0 18A0 3DBB AB10  3E8F FAA0 3F9B 8D10  *<...=...>...?...*
0200  406F DCA0 4184 A990  424F BEA0 4364 8B90  *@o..A...BO..Cd..*
0210  442F A0A0 4544 6D90  45F3 D320 472D 8A10  *D/..EDm.E.. G-..*
0220  47D3 B520 490D 6C10  49B3 9720 4AED 4E10  *G.. I.l.I.. J.N.*
0230  4B9C B3A0 4CD6 6A90  4D7C 95A0 4EB6 4C90  *K...L.j.M|..N.L.*
0240  4F5C 77A0 5096 2E90  513C 59A0 5276 1090  *O\w.P...Q<Y.Rv..*
0250  531C 3BA0 5455 F290  54FC 1DA0 5635 D490  *S.;.TU..T...V5..*
0260  56E5 3A20 581E F110  58C5 1C20 59FE D310  *V.: X...X.. Y...*
0270  5AA4 FE20 5BDE B510  5C84 E020 5DBE 9710  *Z.. [...\.. ]...*
0280  5E64 C220 5F9E 7910  604D DEA0 6187 9590  *^d. _.y.`M..a...*
0290  622D C0A0 6367 7790  640D A2A0 6547 5990  *b-..cgw.d...eGY.*
02A0  65ED 84A0 6727 3B90  67CD 66A0 6907 1D90  *e...g';.g.f.i...*
02B0  69AD 48A0 6AE6 FF90  6B96 6520 6CD0 1C10  *i.H.j...k.e l...*
02C0  6D76 4720 6EAF FE10  6F56 2920 708F E010  *mvG n...oV) p...*
02D0  7136 0B20 726F C210  7315 ED20 744F A410  *q6. ro..s.. tO..*
02E0  74FF 09A0 7638 C090  76DE EBA0 7818 A290  *t...v8..v...x...*
02F0  78BE CDA0 79F8 8490  7A9E AFA0 7BD8 6690  *x...y...z...{.f.*
0300  7C7E 91A0 7DB8 4890  7E5E 73A0 7F98 2A90  *|~..}.H.~^s...*.*
0310  0001 0001 0203 0100  0100 0100 0100 0100  *................*
0320  0100 0100 0100 0100  0100 0100 0100 0100  *................*
0330  0100 0100 0100 0100  0100 0100 0100 0100  *................*
0340  0100 0100 0100 0100  0100 0100 0100 0100  *................*
0350  0100 0100 0100 0100  0100 0100 0100 0100  *................*
0360  0100 0100 0100 0100  0100 0100 0100 0100  *................*
0370  0100 0100 0100 0100  0100 0100 0100 0100  *................*
0380  0100 0100 0100 0100  0100 0100 0100 0100  *................*
0390  0100 0100 0100 0100  0100 0100 0100 0100  *................*
03A0  0100 0100 0100 0100  0100 0100 0100 0100  *................*
03B0  0100 0100 0100 0100  0100 0100 0100 0100  *................*
03C0  0100 0100 0100 0100  01FF FF9D 9001 00FF  *................*
03D0  FF8F 8000 04FF FF9D  9001 08FF FF9D 9001  *................*
03E0  0C50 4454 0050 5354  0050 5754 0050 5054  *.PDT.PST.PWT.PPT*
03F0  0000 0000 0100 0000  0154 5A69 6632 0000  *.........TZif2..*
0400  0000 0000 0000 0000  0000 0000 0000 0000  *................*
0410  0500 0000 0500 0000  0000 0000 BA00 0000  *................*
0420  0500 0000 14FF FFFF  FF5E 041A C0FF FFFF  *.........^......*
0430  FF9E A648 A0FF FFFF  FF9F BB15 90FF FFFF  *...H............*
0440  FFA0 862A A0FF FFFF  FFA1 9AF7 90FF FFFF  *...*............*
0450  FFCB 891A A0FF FFFF  FFD2 23F4 70FF FFFF  *..........#.p...*
0460  FFD2 6126 10FF FFFF  FFD6 FE74 20FF FFFF  *..a&.......t ...*
0470  FFD8 80AD 90FF FFFF  FFDA FED1 A0FF FFFF  *................*
0480  FFDB C090 10FF FFFF  FFDC DEB3 A0FF FFFF  *................*
0490  FFDD A9AC 90FF FFFF  FFDE BE95 A0FF FFFF  *................*
04A0  FFDF 898E 90FF FFFF  FFE0 9E77 A0FF FFFF  *...........w....*
04B0  FFE1 6970 90FF FFFF  FFE2 7E59 A0FF FFFF  *..ip......~Y....*
04C0  FFE3 4952 90FF FFFF  FFE4 5E3B A0FF FFFF  *..IR......^;....*
04D0  FFE5 2934 90FF FFFF  FFE6 4758 20FF FFFF  *..)4......GX ...*
04E0  FFE7 1251 10FF FFFF  FFE8 273A 20FF FFFF  *...Q......': ...*
04F0  FFE8 F233 10FF FFFF  FFEA 071C 20FF FFFF  *...3........ ...*
0500  FFEA D215 10FF FFFF  FFEB E6FE 20FF FFFF  *............ ...*
0510  FFEC B1F7 10FF FFFF  FFED C6E0 20FF FFFF  *............ ...*
0520  FFEE 91D9 10FF FFFF  FFEF AFFC A0FF FFFF  *................*
0530  FFF0 71BB 10FF FFFF  FFF1 8FDE A0FF FFFF  *..q.............*
0540  FFF2 7FC1 90FF FFFF  FFF3 6FC0 A0FF FFFF  *..........o.....*
0550  FFF4 5FA3 90FF FFFF  FFF5 4FA2 A0FF FFFF  *.._.......O.....*
0560  FFF6 3F85 90FF FFFF  FFF7 2F84 A0FF FFFF  *..?......./.....*
0570  FFF8 28A2 10FF FFFF  FFF9 0F66 A0FF FFFF  *..(........f....*
0580  FFFA 0884 10FF FFFF  FFFA F883 20FF FFFF  *............ ...*
0590  FFFB E866 10FF FFFF  FFFC D865 20FF FFFF  *...f.......e ...*
05A0  FFFD C848 10FF FFFF  FFFE B847 20FF FFFF  *...H.......G ...*
05B0  FFFF A82A 1000 0000  0000 9829 2000 0000  *...*.......) ...*
05C0  0001 880C 1000 0000  0002 780B 2000 0000  *..........x. ...*
05D0  0003 7128 9000 0000  0004 6127 A000 0000  *..q(......a'....*
05E0  0005 510A 9000 0000  0006 4109 A000 0000  *..Q.......A.....*
05F0  0007 30EC 9000 0000  0007 8D43 A000 0000  *..0........C....*
0600  0009 10CE 9000 0000  0009 ADBF 2000 0000  *............ ...*
0610  000A F0B0 9000 0000  000B E0AF A000 0000  *................*
0620  000C D9CD 1000 0000  000D C091 A000 0000  *................*
0630  000E B9AF 1000 0000  000F A9AE 2000 0000  *............ ...*
0640  0010 9991 1000 0000  0011 8990 2000 0000  *............ ...*
0650  0012 7973 1000 0000  0013 6972 2000 0000  *..ys......ir ...*
0660  0014 5955 1000 0000  0015 4954 2000 0000  *..YU......IT ...*
0670  0016 3937 1000 0000  0017 2936 2000 0000  *..97......)6 ...*
0680  0018 2253 9000 0000  0019 0918 2000 0000  *.."S........ ...*
0690  001A 0235 9000 0000  001A F234 A000 0000  *...5.......4....*
06A0  001B E217 9000 0000  001C D216 A000 0000  *................*
06B0  001D C1F9 9000 0000  001E B1F8 A000 0000  *................*
06C0  001F A1DB 9000 0000  0020 762B 2000 0000  *......... v+ ...*
06D0  0021 81BD 9000 0000  0022 560D 2000 0000  *.!......."V. ...*
06E0  0023 6ADA 1000 0000  0024 35EF 2000 0000  *.#j......$5. ...*
06F0  0025 4ABC 1000 0000  0026 15D1 2000 0000  *.%J......&.. ...*
0700  0027 2A9E 1000 0000  0027 FEED A000 0000  *.'*......'......*
0710  0029 0A80 1000 0000  0029 DECF A000 0000  *.).......)......*
0720  002A EA62 1000 0000  002B BEB1 A000 0000  *.*.b.....+......*
0730  002C D37E 9000 0000  002D 9E93 A000 0000  *.,.~.....-......*
0740  002E B360 9000 0000  002F 7E75 A000 0000  *...`...../~u....*
0750  0030 9342 9000 0000  0031 6792 2000 0000  *.0.B.....1g. ...*
0760  0032 7324 9000 0000  0033 4774 2000 0000  *.2s$.....3Gt ...*
0770  0034 5306 9000 0000  0035 2756 2000 0000  *.4S......5'V ...*
0780  0036 32E8 9000 0000  0037 0738 2000 0000  *.62......7.8 ...*
0790  0038 1C05 1000 0000  0038 E71A 2000 0000  *.8.......8.. ...*
07A0  0039 FBE7 1000 0000  003A C6FC 2000 0000  *.9.......:.. ...*
07B0  003B DBC9 1000 0000  003C B018 A000 0000  *.;.......<......*
07C0  003D BBAB 1000 0000  003E 8FFA A000 0000  *.=.......>......*
07D0  003F 9B8D 1000 0000  0040 6FDC A000 0000  *.?.......@o.....*
07E0  0041 84A9 9000 0000  0042 4FBE A000 0000  *.A.......BO.....*
07F0  0043 648B 9000 0000  0044 2FA0 A000 0000  *.Cd......D/.....*
0800  0045 446D 9000 0000  0045 F3D3 2000 0000  *.EDm.....E.. ...*
0810  0047 2D8A 1000 0000  0047 D3B5 2000 0000  *.G-......G.. ...*
0820  0049 0D6C 1000 0000  0049 B397 2000 0000  *.I.l.....I.. ...*
0830  004A ED4E 1000 0000  004B 9CB3 A000 0000  *.J.N.....K......*
0840  004C D66A 9000 0000  004D 7C95 A000 0000  *.L.j.....M|.....*
0850  004E B64C 9000 0000  004F 5C77 A000 0000  *.N.L.....O\w....*
0860  0050 962E 9000 0000  0051 3C59 A000 0000  *.P.......Q<Y....*
0870  0052 7610 9000 0000  0053 1C3B A000 0000  *.Rv......S.;....*
0880  0054 55F2 9000 0000  0054 FC1D A000 0000  *.TU......T......*
0890  0056 35D4 9000 0000  0056 E53A 2000 0000  *.V5......V.: ...*
08A0  0058 1EF1 1000 0000  0058 C51C 2000 0000  *.X.......X.. ...*
08B0  0059 FED3 1000 0000  005A A4FE 2000 0000  *.Y.......Z.. ...*
08C0  005B DEB5 1000 0000  005C 84E0 2000 0000  *.[.......\.. ...*
08D0  005D BE97 1000 0000  005E 64C2 2000 0000  *.].......^d. ...*
08E0  005F 9E79 1000 0000  0060 4DDE A000 0000  *._.y.....`M.....*
08F0  0061 8795 9000 0000  0062 2DC0 A000 0000  *.a.......b-.....*
0900  0063 6777 9000 0000  0064 0DA2 A000 0000  *.cgw.....d......*
0910  0065 4759 9000 0000  0065 ED84 A000 0000  *.eGY.....e......*
0920  0067 273B 9000 0000  0067 CD66 A000 0000  *.g';.....g.f....*
0930  0069 071D 9000 0000  0069 AD48 A000 0000  *.i.......i.H....*
0940  006A E6FF 9000 0000  006B 9665 2000 0000  *.j.......k.e ...*
0950  006C D01C 1000 0000  006D 7647 2000 0000  *.l.......mvG ...*
0960  006E AFFE 1000 0000  006F 5629 2000 0000  *.n.......oV) ...*
0970  0070 8FE0 1000 0000  0071 360B 2000 0000  *.p.......q6. ...*
0980  0072 6FC2 1000 0000  0073 15ED 2000 0000  *.ro......s.. ...*
0990  0074 4FA4 1000 0000  0074 FF09 A000 0000  *.tO......t......*
09A0  0076 38C0 9000 0000  0076 DEEB A000 0000  *.v8......v......*
09B0  0078 18A2 9000 0000  0078 BECD A000 0000  *.x.......x......*
09C0  0079 F884 9000 0000  007A 9EAF A000 0000  *.y.......z......*
09D0  007B D866 9000 0000  007C 7E91 A000 0000  *.{.f.....|~.....*
09E0  007D B848 9000 0000  007E 5E73 A000 0000  *.}.H.....~^s....*
09F0  007F 982A 9002 0102  0102 0304 0201 0201  *...*............*
0A00  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0A10  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0A20  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0A30  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0A40  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0A50  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0A60  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0A70  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0A80  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0A90  0201 0201 0201 0201  0201 0201 0201 0201  *................*
0AA0  0201 0201 0201 0201  0201 0201 0201 02FF  *................*
0AB0  FF91 2600 00FF FF9D  9001 04FF FF8F 8000  *..&.............*
0AC0  08FF FF9D 9001 0CFF  FF9D 9001 104C 4D54  *.............LMT*
0AD0  0050 4454 0050 5354  0050 5754 0050 5054  *.PDT.PST.PWT.PPT*
0AE0  0000 0000 0001 0000  0000 010A 5053 5438  *............PST8*
0AF0  5044 542C 4D33 2E32  2E30 2C4D 3131 2E31  *PDT,M3.2.0,M11.1*
0B00  2E30 0A                                   *.0.*
 
Old 01-26-2010, 06:23 PM   #8
suryaemlinux
Member
 
Registered: Mar 2009
Distribution: CentOS, Fedora
Posts: 34

Original Poster
Rep: Reputation: 0
Hi wje_lq,
Thanks for your help. This has been on the sideline for a while. I tried process this file, America/Los_Angeles . The ti_timecnt says 185 but the actual transition times present in this file is only 172 (tzh_timecnt four-byte values). How to encounter this problem? I'm still working on reading other fields as well.


Thanks in Advance,
Surya
 
Old 01-26-2010, 08:01 PM   #9
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 178Reputation: 178
tzh_timecnt is stored in the four bytes at locations 0x20, 0x21, 0x22, and 0x23. The content of those four bytes is 0x00, 0x00, 0x00, and 0xB9, respectively. Since the data is stored big-endian, the number is 0xB9, which is decimal 185, which is what you'd expect.

What do you see as the problem?
 
Old 01-26-2010, 11:59 PM   #10
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 178Reputation: 178
Oh. And. Please refer to the hex dump of the timezone file in one of my prior posts. The first transition time is at location 0x2C. The first byte after the final transition time is at location 0x310. That makes 0x2E4 bytes occupied by transition times, which in decimal is 740, divided by 4 yields 185.
 
Old 01-27-2010, 01:02 PM   #11
suryaemlinux
Member
 
Registered: Mar 2009
Distribution: CentOS, Fedora
Posts: 34

Original Poster
Rep: Reputation: 0
My bad, you caught me at it. I did miss it in my program. After checking with the hexdump I found where the problem was.


Thank you so much,
Surya
 
Old 01-27-2010, 06:34 PM   #12
suryaemlinux
Member
 
Registered: Mar 2009
Distribution: CentOS, Fedora
Posts: 34

Original Poster
Rep: Reputation: 0
And one more thing. All the fileds can be accessed only as char as mentioned in tzfile.h. But the man tzfile says long bytes,etc but it's read correctly when I follow tzfile.h method. Did you try to read it as long bytes rather than char byte(s)?


Thanks,
Surya
 
Old 01-27-2010, 06:48 PM   #13
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 178Reputation: 178
Quote:
Originally Posted by suryaemlinux View Post
Did you try to read it as long bytes rather than char byte(s)?
Um, a four-byte integer is known as "long", not "long bytes". In most contexts of this sort, a "byte" is one character. (International character sets are a completely different topic; we're talking about binary data here.)

The issue is that the data in the file is stored big endian, not little endian; that is, each integer is stored most significant byte first, not least significant byte first. Most of us running Linux on Intel processors would be writing long integers least significant byte first, because that's the way the processor wants to see the data. The most convenient way around this problem is to read the data one (unsigned!) byte at a time and do the arithmetic to form the full long integer.

Beware. If you declare your pointer (or array) as char* or char[], you'll get signed bytes, and your arithmetic will be bad for each byte whose value exceeds 127. You don't want that. Declare your pointer (or array) as unsigned char* or unsigned char[].

More information on this general topic can be found at wikipedia.
 
Old 01-28-2010, 01:11 PM   #14
suryaemlinux
Member
 
Registered: Mar 2009
Distribution: CentOS, Fedora
Posts: 34

Original Poster
Rep: Reputation: 0
Hi wje_lq,
Sorry for my misinterpretation. Actually I meant "long" only not "long bytes". As a software guy, I will be more careful in the future.


Thanks,
Surya
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Timzone and daylight saving time jegra Linux - General 2 11-14-2007 06:02 AM
daylight saving chlawren Linux - General 2 03-27-2007 04:07 AM
new Daylight Saving Time dates dux0r Linux - Software 5 12-28-2006 03:11 PM
DO NOT use Daylight Saving Time - how? EcceVery Debian 4 05-28-2005 03:21 PM
How to setup Daylight Saving Time erick Linux - Software 1 10-15-2003 10:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration