Re: using mktime()
From: Michael Mair (Michael.Mair_at_invalid.invalid)
Date: 02/21/05
- Next message: Christopher Benson-Manica: "Re: Is correct ?"
- Previous message: Al Bowers: "Re: using mktime()"
- In reply to: Al Bowers: "Re: using mktime()"
- Next in thread: Al Bowers: "Re: using mktime()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 21 Feb 2005 15:30:40 +0100
Al Bowers wrote:
> 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.
Read it just this weekend in C Unleashed, so I am sure the range
is 0..60; however we can have the look at the standard:
"7.23.1 Components of time
....
4 The range and precision of times representable in clock_t and time_t
are implementation-defined. The tm structure shall contain at least the
following members, in any order. The semantics of the members and their
normal ranges are expressed in the comments.265)
int tm_sec; // seconds after the minute [0, 60]
int tm_min; // minutes after the hour [0, 59]
int tm_hour; // hours since midnight [0, 23]
int tm_mday; // day of the month [1, 31]
int tm_mon; // months since January [0, 11]
int tm_year; // years since 1900
int tm_wday; // days since Sunday [0, 6]
int tm_yday; // days since January 1 [0, 365]
int tm_isdst; // Daylight Saving Time flag
________________________________________________________________________
265) The range [0, 60] for tm_sec allows for a positive leap second.
"
Cheers
Michael
-- E-Mail: Mine is a gmx dot de address.
- Next message: Christopher Benson-Manica: "Re: Is correct ?"
- Previous message: Al Bowers: "Re: using mktime()"
- In reply to: Al Bowers: "Re: using mktime()"
- Next in thread: Al Bowers: "Re: using mktime()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|