Questions about mktime()
D'Arcy J.M. Cain
darcy at druid.uucp
Sat Jan 19 09:51:55 AEST 1991
I am trying to write an ANSI compatible mktime() and I have a few
questions.
I am using the tm_year, tm_mon tm_mday, tm_hour, tm_min and tm_sec
members of the tm structure to calculate the number of seconds. If
the information in the other members happens to conflict with the
result must I return an error or can I safely ignore the others?
According to K&R2 the argument to mktime is not a const. Does this
mean that I can modify the structure? It seems to me that it would
be convenient to reset it with localtime() to set the other members
to sane values.
Is there a simple way to adjust for the time zone? I considered
t += timezone;
but that doesn't handle daylight saving time. I then considered
t += tp->tm_isdst ? altzone : timezone;
but I can't rely on the tm_isdst being correct, or can I? My
feeling is that the user can throw in whatever date and time and
mktime() should be able to figure out time zones.
Any help appreciated.
--
D'Arcy J.M. Cain (darcy at druid) |
D'Arcy Cain Consulting | There's no government
West Hill, Ontario, Canada | like no government!
+1 416 281 6094 |
More information about the Comp.std.c
mailing list