Re: using mktime()
From: Al Bowers (lbowers21_at_cox.net)
Date: 02/21/05
- Previous message: Ron Natalie: "Re: what is .i file?"
- In reply to: Dave Thompson: "Re: using mktime()"
- Next in thread: Michael Mair: "Re: using mktime()"
- Reply: Michael Mair: "Re: using mktime()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 21 Feb 2005 08:20:39 -0600
Dave Thompson wrote:
>>>
>>>
>>No. What the Standard says is that function mktime will bring
>>all values into range. For example the range for struct tm member
>>
>>
>
>If the call is successful, yes. It (definitely) won't be if the
>requested time is not representable in time_t, and it's not clear if
>mktime() is allowed to fail in other cases that the implementor
>decides are "too hard" -- the comments in the Olson public-domain
>implementation imply to me that this might have happened.
>
>
>
Yes, the Standard does not specify anthing on the resulting values of
the struct tm
members should and and when an implement of function mktime decides that
time is
not representable. The values may be changed or unchanged, in part or
in total.
>>tm_sec is 0-59. If tm_sec has the value of say -69 the function
>>mktime will bring tm_sec into range by subtracting 1 from tm_min.
>>
>>
>
>Actually tm_sec is 0-60 to allow for (positive) leap seconds, which
>are rarely if ever implemented. That is, leap seconds actually happen
>(for now, there has been discussion of eliminating them) but (most?) C
>implementations (and systems) just treat them as transient errors.
>The only people I've heard of actually using them are the ones for
>whom they were designed -- astronomers and space navigators, and their
>only contact to most ordinary people, GPS.
>
>
>
I believe the Standard specifies the representable range as 0-59. I do
not recall any mention
of leap seconds in the Standard. Perhaps you are referring to an
implement that extends
the Standard. Unfortumately, I will be away from headquarters for a
week, and not have
access to the Standard document. Please correct me if I am wrong.
>Presumably you meant -60sec = -1min. -69sec = -2min leaving 51sec.
>
>
>
Yes, the result to bring tm_sec into range would be a decrease of 2 in
tm_min and an
increase of 120 in tm_sec to bring it's value in range at 51 (120-69).
>>And on up the ladder, if necessary, until finally tm_mon and
>>tm_year are determined. Then tm_wday and tm_yday components of the
>>struct are set appropriately. I would think that a Standard C
>>that would allow you to add to a time but make reducing it undefined
>>would be unwise.
>>
>>
>
>
>
Al Bowers
- Previous message: Ron Natalie: "Re: what is .i file?"
- In reply to: Dave Thompson: "Re: using mktime()"
- Next in thread: Michael Mair: "Re: using mktime()"
- Reply: Michael Mair: "Re: using mktime()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|