[1003.1(2016/18)/Issue7+TC2 0001627]: XSH 3 / mktime() is woefully underspecified
The following issue has a resolution that has been APPLIED. == https://austingroupbugs.net/view.php?id=1627 == Reported By:kre Assigned To: == Project:1003.1(2016/18)/Issue7+TC2 Issue ID: 1627 Category: System Interfaces Type: Enhancement Request Severity: Objection Priority: normal Status: Applied Name: Robert Elz Organization: User Reference: Section:XSH 3/mktime Page Number:1331 Line Number:44310-44332, 44361 Interp Status: --- Final Accepted Text:https://austingroupbugs.net/view.php?id=1627#c6415 Resolution: Accepted As Marked Fixed in Version: == Date Submitted: 2023-01-05 12:17 UTC Last Modified: 2023-09-04 10:34 UTC == Summary:XSH 3 / mktime() is woefully underspecified == Relationships ID Summary -- related to 0001614 XSH 3/mktime does not specify EINVAL an... == Issue History Date ModifiedUsername FieldChange == 2023-01-05 12:17 kreNew Issue 2023-01-05 12:17 kreName => Robert Elz 2023-01-05 12:17 kreSection => XSH 3/mktime 2023-01-05 12:17 krePage Number => 1331 2023-01-05 12:17 kreLine Number => 44310-44332, 44361 2023-01-20 20:54 mirabilos Note Added: 0006118 2023-07-25 14:09 geoffclare Relationship added related to 0001614 2023-08-07 09:05 geoffclare Note Added: 0006415 2023-08-07 09:06 geoffclare Note Edited: 0006415 2023-08-14 12:01 mirabilos Note Added: 0006429 2023-08-14 15:16 geoffclare Interp Status => --- 2023-08-14 15:16 geoffclare Final Accepted Text => https://austingroupbugs.net/view.php?id=1627#c6415 2023-08-14 15:16 geoffclare Status New => Resolved 2023-08-14 15:16 geoffclare Resolution Open => Accepted As Marked 2023-08-14 15:16 geoffclare Desired Action Updated 2023-08-14 15:17 geoffclare Tag Attached: issue8 2023-09-04 10:34 geoffclare Status Resolved => Applied ==
[1003.1(2016/18)/Issue7+TC2 0001627]: XSH 3 / mktime() is woefully underspecified
The following issue has been RESOLVED. == https://austingroupbugs.net/view.php?id=1627 == Reported By:kre Assigned To: == Project:1003.1(2016/18)/Issue7+TC2 Issue ID: 1627 Category: System Interfaces Type: Enhancement Request Severity: Objection Priority: normal Status: Resolved Name: Robert Elz Organization: User Reference: Section:XSH 3/mktime Page Number:1331 Line Number:44310-44332, 44361 Interp Status: --- Final Accepted Text:https://austingroupbugs.net/view.php?id=1627#c6415 Resolution: Accepted As Marked Fixed in Version: == Date Submitted: 2023-01-05 12:17 UTC Last Modified: 2023-08-14 15:16 UTC == Summary:XSH 3 / mktime() is woefully underspecified == Relationships ID Summary -- related to 0001614 XSH 3/mktime does not specify EINVAL an... == Issue History Date ModifiedUsername FieldChange == 2023-01-05 12:17 kreNew Issue 2023-01-05 12:17 kreName => Robert Elz 2023-01-05 12:17 kreSection => XSH 3/mktime 2023-01-05 12:17 krePage Number => 1331 2023-01-05 12:17 kreLine Number => 44310-44332, 44361 2023-01-20 20:54 mirabilos Note Added: 0006118 2023-07-25 14:09 geoffclare Relationship added related to 0001614 2023-08-07 09:05 geoffclare Note Added: 0006415 2023-08-07 09:06 geoffclare Note Edited: 0006415 2023-08-14 12:01 mirabilos Note Added: 0006429 2023-08-14 15:16 geoffclare Interp Status => --- 2023-08-14 15:16 geoffclare Final Accepted Text => https://austingroupbugs.net/view.php?id=1627#c6415 2023-08-14 15:16 geoffclare Status New => Resolved 2023-08-14 15:16 geoffclare Resolution Open => Accepted As Marked 2023-08-14 15:16 geoffclare Desired Action Updated ==
[1003.1(2016/18)/Issue7+TC2 0001627]: XSH 3 / mktime() is woefully underspecified
A NOTE has been added to this issue. == https://austingroupbugs.net/view.php?id=1627 == Reported By:kre Assigned To: == Project:1003.1(2016/18)/Issue7+TC2 Issue ID: 1627 Category: System Interfaces Type: Enhancement Request Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XSH 3/mktime Page Number:1331 Line Number:44310-44332, 44361 Interp Status: --- Final Accepted Text: == Date Submitted: 2023-01-05 12:17 UTC Last Modified: 2023-08-14 12:01 UTC == Summary:XSH 3 / mktime() is woefully underspecified == Relationships ID Summary -- related to 0001614 XSH 3/mktime does not specify EINVAL an... == -- (0006429) mirabilos (reporter) - 2023-08-14 12:01 https://austingroupbugs.net/view.php?id=1627#c6429 -- Much love for the extra effort here, and to distinguish between “go forward one minute” and “go forward 60 seconds” is interesting in “breaks in time” cases (like leap seconds). Thank you! Issue History Date ModifiedUsername FieldChange == 2023-01-05 12:17 kreNew Issue 2023-01-05 12:17 kreName => Robert Elz 2023-01-05 12:17 kreSection => XSH 3/mktime 2023-01-05 12:17 krePage Number => 1331 2023-01-05 12:17 kreLine Number => 44310-44332, 44361 2023-01-20 20:54 mirabilos Note Added: 0006118 2023-07-25 14:09 geoffclare Relationship added related to 0001614 2023-08-07 09:05 geoffclare Note Added: 0006415 2023-08-07 09:06 geoffclare Note Edited: 0006415 2023-08-14 12:01 mirabilos Note Added: 0006429 ==
[1003.1(2016/18)/Issue7+TC2 0001627]: XSH 3 / mktime() is woefully underspecified
A NOTE has been added to this issue. == https://austingroupbugs.net/view.php?id=1627 == Reported By:kre Assigned To: == Project:1003.1(2016/18)/Issue7+TC2 Issue ID: 1627 Category: System Interfaces Type: Enhancement Request Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XSH 3/mktime Page Number:1331 Line Number:44310-44332, 44361 Interp Status: --- Final Accepted Text: == Date Submitted: 2023-01-05 12:17 UTC Last Modified: 2023-08-07 09:05 UTC == Summary:XSH 3 / mktime() is woefully underspecified == Relationships ID Summary -- related to 0001614 XSH 3/mktime does not specify EINVAL an... == -- (0006415) geoffclare (manager) - 2023-08-07 09:05 https://austingroupbugs.net/view.php?id=1627#c6415 -- Suggested resolution ... On page 113 line 3186 section 4.16 Seconds Since the Epoch, change:The relationship between the actual time of day and the current value for seconds since the Epoch is unspecified.to:The relationship between the actual date and time in Coordinated Universal Time, as determined by the International Earth Rotation Service, and the system's current value for seconds since the Epoch is unspecified. On page 1331 line 44320 section mktime(), after applying bugs 1613 and 1614 change:The relationship between the tm structure (defined in the header) and the time in seconds since the Epoch is that the result shall be as specified in the expression given in the definition of seconds since the Epoch (see [xref to XBD 4.19]) corrected for the offset of the timezone's standard time from Coordinated Universal Time and further corrected (if applicable--see below) for Daylight Saving Time, where the names other than tm_yday in the structure and in the expression correspond, and the tm_yday value used in the expression is the day of the year from 0 to 365 inclusive, calculated from the members of the tm structure specified above.to:The mktime() function shall calculate the time in seconds since the Epoch to be returned as if by manipulating the members of the tm structure according to the following steps. 1. The tm_sec member may, but should not, be brought into the range 0 to 60, inclusive. For each 60 seconds added to or subtracted from tm_sec, a decrement or increment, respectively, of 1 minute shall be saved for later application. 2. The tm_min member shall be brought into the range 0 to 59, inclusive, and any saved decrement or increment of minutes shall then be applied, repeating the range adjustment afterwards if necessary. For each 60 minutes added to or subtracted from tm_min, a decrement or increment, respectively, of 1 hour shall be saved for later application. 3. The tm_hour member shall be brought into the range 0 to 23, inclusive, and any saved decrement or increment of hours shall then be applied, repeating the range adjustment afterwards if necessary. For each 24 hours added to or subtracted from tm_hour, a decrement or increment, respectively, of 1 day shall be saved for later application. 4. The tm_mon member shall be brought into the range 0 to 11, inclusive. For each 12 months added to or subtracted from tm_mon, a decrement or increment, respectively, of 1 year shall be saved for later use. 5. The tm_mday member shall be brought into the range 1 to 31, inclusive, and any saved decrement or increment of days shall then be applied, repeating the range adjustment afterwards if necessary. Adjustments downwards shall be applied by subtracting the number of days (according to the Gregorian calendar) in month tm_mon+1 of the year obtained by adding/subtracting any saved increment/decrement of years to the value tm_year+1900, and then incrementing tm_mon by 1, repeated as necessary. Adjustments upwards shall be applied by adding the number of days in the month before month tm_mon+1 of the year obtained by adding/subtracting any saved increment/decrement of years to the value tm_year+1900, and
[1003.1(2016/18)/Issue7+TC2 0001627]: XSH 3 / mktime() is woefully underspecified
The following issue has been set as RELATED TO issue 0001614. == https://austingroupbugs.net/view.php?id=1627 == Reported By:kre Assigned To: == Project:1003.1(2016/18)/Issue7+TC2 Issue ID: 1627 Category: System Interfaces Type: Enhancement Request Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XSH 3/mktime Page Number:1331 Line Number:44310-44332, 44361 Interp Status: --- Final Accepted Text: == Date Submitted: 2023-01-05 12:17 UTC Last Modified: 2023-01-20 20:54 UTC == Summary:XSH 3 / mktime() is woefully underspecified == Relationships ID Summary -- related to 0001614 XSH 3/mktime does not specify EINVAL an... == Issue History Date ModifiedUsername FieldChange == 2023-01-05 12:17 kreNew Issue 2023-01-05 12:17 kreName => Robert Elz 2023-01-05 12:17 kreSection => XSH 3/mktime 2023-01-05 12:17 krePage Number => 1331 2023-01-05 12:17 kreLine Number => 44310-44332, 44361 2023-01-20 20:54 mirabilos Note Added: 0006118 2023-07-25 14:09 geoffclare Relationship added related to 0001614 ==
[1003.1(2016/18)/Issue7+TC2 0001627]: XSH 3 / mktime() is woefully underspecified
A NOTE has been added to this issue. == https://austingroupbugs.net/view.php?id=1627 == Reported By:kre Assigned To: == Project:1003.1(2016/18)/Issue7+TC2 Issue ID: 1627 Category: System Interfaces Type: Enhancement Request Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XSH 3/mktime Page Number:1331 Line Number:44310-44332, 44361 Interp Status: --- Final Accepted Text: == Date Submitted: 2023-01-05 12:17 UTC Last Modified: 2023-01-20 20:54 UTC == Summary:XSH 3 / mktime() is woefully underspecified == -- (0006118) mirabilos (reporter) - 2023-01-20 20:54 https://austingroupbugs.net/view.php?id=1627#c6118 -- Don’t break mktime of a valid struct with tm_sec=60 pointing to a leap second, please. Issue History Date ModifiedUsername FieldChange == 2023-01-05 12:17 kreNew Issue 2023-01-05 12:17 kreName => Robert Elz 2023-01-05 12:17 kreSection => XSH 3/mktime 2023-01-05 12:17 krePage Number => 1331 2023-01-05 12:17 kreLine Number => 44310-44332, 44361 2023-01-20 20:54 mirabilos Note Added: 0006118 ==
[1003.1(2016/18)/Issue7+TC2 0001627]: XSH 3 / mktime() is woefully underspecified
The following issue has been SUBMITTED.
==
https://austingroupbugs.net/view.php?id=1627
==
Reported By:kre
Assigned To:
==
Project:1003.1(2016/18)/Issue7+TC2
Issue ID: 1627
Category: System Interfaces
Type: Enhancement Request
Severity: Objection
Priority: normal
Status: New
Name: Robert Elz
Organization:
User Reference:
Section:XSH 3/mktime
Page Number:1331
Line Number:44310-44332, 44361
Interp Status: ---
Final Accepted Text:
==
Date Submitted: 2023-01-05 12:17 UTC
Last Modified: 2023-01-05 12:17 UTC
==
Summary:XSH 3 / mktime() is woefully underspecified
Description:
Following on from notes added to bug:1614 and a lengthy
mailing list discussion, it is evident that the specification
of XSH/mktime is woefully inadequate.
New text is specified in the Desired Action to remedy those defects.
This is currently missing anything dealing with what should be done
if the input tm_isdst is not < 0, and does not agree (in sign, if 0
can be said to have a sign) with the final value for tm_isdst in the
struct tm on a successful return.
That's because my inclination is to simply do nothing in that case,
return the correct tm_isdst, but otherwise ignore it - but I admit that's
not how the implementations behave, and that may be being depended upon
by some applications (though the current behaviour is definitely not
required by any standard). So I will leave it for someone who cares
about that to add suitable text to (properly) specify what is to happen.
Also, given that it is too late now to consider adding a timegm()
function (an analog to mktime() which has existed for decades, but
never been standardised) I thought what might be possible would be
to specify enough in the FUTURE DIRECTIONS here to indicate that that
will happen (since it is being added to the C standard, it will happen,
eventually) and to indicate why using it is a much better idea when
the purpose is time_t arithmetic than using localtime()/mktime().
The intent is to get applications to start writing safe code, rather
than nonsense, and do that asap - since in practice, timegm() is
already widely available.
As usual, formatting and wording changes, which keep to the general
intent expressed below are welcome.One thing I considered, but
wasn't sure of a good way to handle, was to find some shorter way
to express "the converted value of the struct tm referred to by
timeptr" (or a field thereof) - which occurs far too often in the
text below, and is unwieldy.
Desired Action:
Delete the (CX shaded) paragraph that starts (line 44310)
A positive or 0 value for tm_isdst ...
and ends (line 44313)
... is in effect for the specified time.
Replace the (CX) shaded paragraph that starts (line 44315)
The relationship between the tm structure ...
and ends(line 44321)
... the other tm structure members specified in
(excluding tm_wday).
with the following (presumably also CX shaded) paragraphs:
The mktime() function will first convert the tm_sec, tm_min,
tm_hour, tm_mon, tm_mday and tm_mon (again) fields of the tm
structure referenced by timeptr (or a local internal copy
thereof),
in that order, so that their values become within the ranges
specified
by , but also within the ranges applicable to a Gregorian
Calendar date (tm_sec shall not be more than 59, and tm_mday shall
not be more than the number of days in the month specified by
the tm_mon field of the year specified by the tm_year field).
If _field_ represents the field being converted, and _next_
represents the field specified immediately after it in
then this shall be done, for each field, by an algorithm
equivalent
to:
if (timeptr->_field_ < MINIMUM_VALUE) {
while (timeptr->_field_ < MINIMUM_VALUE) {
timeptr->_field_ += RANGE;
timeptr->_next_--; /* check overflow
*/
}
} else if (timeptr->_field_ > MAXIMUM_VALUE) {
while (timeptr->_field_ > MAXIMUM_VALUE) {
timeptr->_field_ -= RANGE;
timeptr->_next_++; /* check overflow
*/
