|
Home > Archive > Unix Programming > March 2004 > Seeking Useful Variant of mktime
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Seeking Useful Variant of mktime
|
|
| John Michael Davison 2004-03-18, 4:35 pm |
| Given the abysmal specification (and implementations) of the "mktime"
function in C89, C99, C++98, and the Open Group Base Specifications
Issue 6, IEEE Std 1003.1, 2003 Edition, I am looking for something
akin to "mktime" which, in addition to attempting to produce a valid
time_t, can distinguish among the following states of the submitted
"struct tm *timeptr" (or equivalent) and inform the caller:
1. *timeptr indicates a time specification that lies in a period of
time during which Daylight Saving Time is known to be in effect
2. *timeptr indicates a time specification that lies in a period of
time during which Daylight Saving Time is known not to be in effect
3. *timeptr indicates a time specification that is known to lie in the
"fall-backward fold" that results from switching from Daylight Saving
Time to Standard Time
4. *timeptr indicates a time specification that is known to lie in the
"spring-forward gap" that results from switching from Standard Time to
Daylight Saving Time
5. *timeptr is a well-formed time specification, but the environment
lacks the Daylight Saving Time information necessary to distinguish
among #1, #2, #3, and #4
6. *timeptr is a malformed time specification irrespective of Daylight
Saving Ti
me concerns
(Have I missed any cases?)
It is possible to write such code in UNIX?
Relevant USENET threads:
"Can mktime return -1 for times in the spring-forward gap?"
comp.std.c, March-April 1994.
"mktime murk"
comp.std.c, October 1995.
| |
| Claudio Puviani 2004-03-18, 10:35 pm |
| "John Michael Davison" <jdavison@speakeasy.org> wrote
> Given the abysmal specification (and implementations) of the "mktime"
> function in C89, C99, C++98, and the Open Group Base Specifications
> Issue 6, IEEE Std 1003.1, 2003 Edition, I am looking for something
> akin to "mktime" which, in addition to attempting to produce a valid
> time_t, can distinguish among the following states of the submitted
> "struct tm *timeptr" (or equivalent) and inform the caller:
>
> 1. *timeptr indicates a time specification that lies in a period of
> time during which Daylight Saving Time is known to be in effect
>
> 2. *timeptr indicates a time specification that lies in a period of
> time during which Daylight Saving Time is known not to be in effect
>
> 3. *timeptr indicates a time specification that is known to lie in the
> "fall-backward fold" that results from switching from Daylight Saving
> Time to Standard Time
>
> 4. *timeptr indicates a time specification that is known to lie in the
> "spring-forward gap" that results from switching from Standard Time to
> Daylight Saving Time
>
> 5. *timeptr is a well-formed time specification, but the environment
> lacks the Daylight Saving Time information necessary to distinguish
> among #1, #2, #3, and #4
>
> 6. *timeptr is a malformed time specification irrespective of Daylight
> Saving Ti
> me concerns
>
> (Have I missed any cases?)
>
> It is possible to write such code in UNIX?
>
> Relevant USENET threads:
>
> "Can mktime return -1 for times in the spring-forward gap?"
> comp.std.c, March-April 1994.
>
> "mktime murk"
> comp.std.c, October 1995.
Here's your best source for date/time manipulations, though some would argue
that being able to convert to and from the Mayan calendar might be a bit of an
overkill:
http://search.barnesandnoble.com/bo...isbn=0879304960
|
|
|
|
|