This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Timezone : DST change
- From: Geert Jordaens <geert dot jordaens at telenet dot be>
- To: libc-alpha at sources dot redhat dot com
- Date: Sun, 09 Mar 2008 12:23:47 +0100
- Subject: Timezone : DST change
I don't know if this is the right address to send this feature
request/proposition.
What would be against extending glibc with a functionality that allows
to calculate the time_t representation of a DST switch?
exmple :
time_t time_nt;
time_t time_dst;
putenv("TZ=europe/brussels");
year = 2008;
isdst = 0;
time_nt = dstchange(year, isdst); // would return the switch time_t from
DST to normal time (0 if no switch)
isdst = 1;
time_dst = dstchange(year, isdst); // would return the switch time_t
from normal tot DST to time (0 if no switch)
Add to tzset.c
time_t
__tz_compute_dst_change(year, isdst)
int year;
int isdst;
{
time_t change = 0;
__libc_lock_lock (tzset_lock);
tzset_internal (1, 1);
isdst = (isdst==0)?0:1;
compute_change (&tz_rules[isdst], year);
change = tz_rules[isdst].change;
__libc_lock_unlock (tzset_lock);
return change;
}
Create dstchange.c
/* Return the `struct tm' representation of *T in UTC. */
time_t
dstchange (year, isdst)
int year;
int isdst;
{
return __tz_compute_dst_change(year, isdst);
}
libc_hidden_def (dstchange)
Adapt the header files.
Geert Jordaens