I got the following useful suggestion from my last post:
From: Michael Beach <firstname.lastname@example.org>
Upon checking my mktime(3) manpage under Linux, it says that tm_wday and
tm_yday fields of the tm struct are ignored, and recomputed, but that if
the broken down time cannot be rpresented as a calendar time, the function
returns (time_t)(-1) and __does not alter__ tm_wday and tm_yday.
Assuming this behaviour is part of POSIX and not just a Linux
implementation quirk, would it not be possible to set tm_wday or tm_yday
to an illegal value prior to the call to mktime(3), then examine the value
upon return. If the value is unchanged, then an error must have occurred,
regardless of the return value.
If it's required, it would definitely solve the problem.
I have checked my POSIX spec, which is silent on this issue. It does, however,
say that POSIX mktime() is required to be compliant with the ANSI C spec for
mktime(). I do not have that spec (just the ANSI K&R). Does anyone have a
copy of the spec, and if so, could they look it up for me?