This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Format of "__tzinfo_type tzinfo"


It is not necessary to know what the members are in able to use it, as the
user should be using the higher-level routines.  Read the man page for tzset,
which explains how the TZ environment variable should be set.  (The newlib
tzset man page does not describe it completely, but Linux does, if you
have access to that.  Otherwise it should readily be available on the web.)
 
For example, I am in the EST/EDT zone, which changes to daylight time (EDT)
on the second Sunday in March (M3.2.0), and back to standard time (EST)
the first Sunday in November (M11.1.0).  Eastern time is 5 hours behind
GMT, so EST5, while EDT is only 4 hours behind, so EDT4.  (The routines
default to changing at 2AM, so my setting keeps that default.)
 
putenv("TZ=EST5EDT4,M3.2.0,M11.1.0");
 
/* Print local time, showing time zone in use */
time_t  t=time(NULL);
if(t != (time_t)-1)  {
    /* Include time zone in printout (if have) */
    char  buf[40];
    const char  *fmt="%a %b %e %H:%M:%S %Z %Y";
    struct tm  *tm_p;
    tm_p = localtime(&t);
    strftime(buf, sizeof(buf), fmt, tm_p);
    puts(buf);
    }

Sample output:
Tue Jun  3 14:12:07 EDT 2008
 
I am not familiar with your zone, but it would be something like
"TZ=CET-2CEST-1,M3.5.0/01:00:00,M10.5.0/01:00:00" if the CEST article on
Wikipedia had the right information (changing at 1AM the last Sunday
of March and the last Sunday of October, normally 2 hours ahead of GMT).
 
Craig

-----Original Message-----
From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org] On Behalf Of Heiko
Sent: Tuesday, June 03, 2008 4:31 AM
To: newlib@sources.redhat.com
Subject: Format of "__tzinfo_type tzinfo"

Hello,

I´ll use the time-functions from newlib.
Can somebody explain me the meaning of the elements from "__tzinfo_type
tzinfo" (\libc\time\gettzinfo.c)?

  typedef struct __tzrule_struct
  {
    char ch;
    int m;
    int n;
    int d;
    int s;
    time_t change;
    long offset; /* Match type of _timezone. */
  } __tzrule_type;

  typedef struct __tzinfo_struct
  {
    int __tznorth;
    int __tzyear;
    __tzrule_type __tzrule[2];
  } __tzinfo_type;

I need it for conversion from UTZ to CET/CEST.

Thanks and wbr
Heiko


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]