List Info

Thread: Format of "__tzinfo_type tzinfo"




Format of "__tzinfo_type tzinfo"
user name
2008-06-03 03:31:04
Hello,

IŽll use the time-functions from newlib.
Can somebody explain me the meaning of the elements from
"__tzinfo_type
tzinfo" (libctimegettzinfo.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

-- 
http://www.fastmail.fm
- Access your email from home and the web


RE: Format of "__tzinfo_type tzinfo"
country flaguser name
United States
2008-06-03 13:29:13
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-ownersourceware.org [mailto:newlib-ownersourceware.org] On Behalf Of Heiko
Sent: Tuesday, June 03, 2008 4:31 AM
To: newlibsources.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" (libctimegettzinfo.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


Re: Format of "__tzinfo_type tzinfo"
user name
2008-06-03 15:00:55
Howland Craig D (Craig) wrote:
> 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.)
>  
>   
I'll update the docs to clarify the start and end date
formats.
> 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-ownersourceware.org [mailto:newlib-ownersourceware.org] On Behalf Of Heiko
> Sent: Tuesday, June 03, 2008 4:31 AM
> To: newlibsources.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" (libctimegettzinfo.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
>
>   


RE: Format of "__tzinfo_type tzinfo"
user name
2008-06-04 01:32:49
Hello,

I donŽt have environment-variables.
In the meantime I set tzinfo in my src:

static __tzinfo_type tzinfo = {1, 0,
    { {'M', 3, 5, 0, 7200, (time_t)0, -3600 },   //CET,
March, Last
    week, Sunday, 2:00 oŽclock, -1 hour to UTC
      {'M', 10, 5, 0, 10800, (time_t)0, -7200 }  //CET,
October, Last
      week, Sunday, 3:00 oŽclock, -2 hours to UTC
    } 
};

I also wrote my own tzset().
void tzset (void)
{
  __tzinfo_type *tz = __gettzinfo();      
  __tzcalc_limits (tz->__tzyear);
  _timezone = tz->__tzrule[0].offset;  
  _daylight = tz->__tzrule[0].offset !=
tz->__tzrule[1].offset;
  _tzname[0] = tz->__tzrule[0].name;
  _tzname[1] = tz->__tzrule[1].name;
  os_mut_release(MUTEX_TIMEZONE); 
}

At the moment, it seems to work. 
Perhaps it will not work if I have no daylight-saving-time.
(I must test
it...)

Wbr 
Heiko

On Tue, 3 Jun 2008 14:29:13 -0400, "Howland Craig D
(Craig)"
<howlandLGSInnovations.com> said:
> 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-ownersourceware.org [mailto:newlib-ownersourceware.org] On
> Behalf Of Heiko
> Sent: Tuesday, June 03, 2008 4:31 AM
> To: newlibsources.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" (libctimegettzinfo.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
> 

-- 
http://www.fastmail.fm
- The professional email service


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )