Tue, 21 Sep 1999 16:45:21 -0400
Quote:
> I'm trying to convert time_t values to their text equivalents on Wintel systems
> (NT 4 SP5). The problem I'm having is due to daylight savings time (DST)
> adjustments made by calls to localtime(). Take, for example, April 2, 2000
> 6:00AM. When I pass the time_t value representing the April date to localtime()
> and pass that result to asctime(), I get April 2, 2000 7:00AM. This only
> happens on DST transition days (first sunday in Apr and last sunday in Oct
> after 2:00AM). I don't want this time adjustment to show up in the result of
> asctime(). Does anyone know how to turn this off or to determine the number of
> the Sunday in month; whether is first, second, etc.?
You want the remainder of the transition days (from 2am on)
to use the system before the transition, but not other days?
Are you sure? Won't this cause all your users to be one hour
early or late for whatever the event is?
After localtime (or other functions that set/normalize struct tm),
if tm_wday == 0 (Sunday), and tm_mday <= 7 it's the first Sunday;
if tm_mday >= mon_len(tm_mon,isleapyear)-6 it's the last Sunday.
Or convert a time_t for midnight (before the transition) and
set tm_hour,tm_min,tm_sec yourself before calling asctime.
Although not required or guaranteed by the C standard,
WinNT follows the Unix/POSIX rule that time_t is seconds
with an origin at 00:00 GMT/UTC (on Jan 1 1970) so
it's easy to split (sequential) days and time-of-day.
(CCed) david.thompson at but not for trintech.com