Skip to content

Commit

Permalink
Revert "leapDay" stuff. Too early for 9.0.1. Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Nov 23, 2024
2 parents 12c3809 + 31e18d8 commit dc77560
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 38 deletions.
1 change: 0 additions & 1 deletion changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Release Tcl 9.0.1 arises from the check-in with tag `core-9-0-1`.
- [zlib-8.8, zlib-8.16 fail on Fedora 40, gcc 14.1.1](https://core.tcl-lang.org/tcl/tktview/73d5cb)
- [regression in tzdata, %z instead of offset TZ-name](https://core.tcl-lang.org/tcl/tktview/2c237b)
- [Tcl will not start properly if there is an init.tcl file in the current dir](https://core.tcl-lang.org/tcl/tktview/43c94f)
- [clock scan of leapsecond: wrong result](https://core.tcl-lang.org/tcl/tktview/f2b5f8)
- [clock scan "24:00", ISO-8601 compatibility](https://core.tcl-lang.org/tcl/tktview/aee9f2)
- [install registry and dde in $INSTALL_DIR\lib always](https://core.tcl-lang.org/tcl/tktview/364bd9)
- [cannot build .chm help file (Windows)](https://core.tcl-lang.org/tcl/tktview/bb110c)
Expand Down
7 changes: 5 additions & 2 deletions doc/clock.n
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,8 @@ A time of day, which is of the form:
or
.QW "\fBhhmm \fR?\fBmeridian\fR? ?\fBzone\fR?" .
If no \fImeridian\fR is specified, \fIhh\fR is interpreted on
a 24-hour clock.
a 24-hour clock. The "24:00" and "24:00:00" formats (with or without
colon) are supported only if no \fImeridian\fR is specified.
.TP
\fIdate\fR
.
Expand Down Expand Up @@ -951,7 +952,9 @@ or
.QW "\fICCyy-mm-dd\fBT\fIhh:mm:ss\fR" .
Note that only these four formats are accepted.
The command does \fInot\fR accept the full range of point-in-time
specifications specified in ISO8601. Other formats can be recognized by
specifications specified in ISO8601. For example, leap seconds are
not supported. The "24:00" and "24:00:00" formats (with or without
colon) are supported. Other formats can be recognized by
giving an explicit \fB\-format\fR option to the \fBclock scan\fR command.
.TP
\fIrelative time\fR
Expand Down
31 changes: 1 addition & 30 deletions generic/tclClock.c
Original file line number Diff line number Diff line change
Expand Up @@ -3785,7 +3785,6 @@ ClockValidDate(
const char *errMsg = "", *errCode = "";
TclDateFields temp;
int tempCpyFlg = 0;
int leapDay = -1;
ClockClientData *dataPtr = opts->dataPtr;

#if 0
Expand All @@ -3810,9 +3809,6 @@ ClockValidDate(
errCode = "iso year";
goto error;
}
if ((yydate.iso8601Year < 1972) || (yydate.iso8601Year > 2017)) {
leapDay = 0;
}
}
if (info->flags & CLF_YEAR) {
if (yyYear < dataPtr->validMinYear
Expand All @@ -3821,9 +3817,6 @@ ClockValidDate(
errCode = "year";
goto error;
}
if ((yyYear < 1972) || (yyYear > 2017)) {
leapDay = 0;
}
} else if ((info->flags & CLF_ISO8601YEAR)) {
yyYear = yydate.iso8601Year; /* used to recognize leap */
}
Expand All @@ -3842,22 +3835,6 @@ ClockValidDate(
errMsg = "invalid month";
errCode = "month";
goto error;
} else if (leapDay) {
switch (yyMonth) {
case 6:
leapDay = 30;
break;
case 12:
leapDay = 31;
break;
case 1:
case 7:
leapDay = 1;
break;
default:
leapDay = 0;
break;
}
}
}
/* day of month */
Expand All @@ -3866,8 +3843,6 @@ ClockValidDate(
errMsg = "invalid day";
errCode = "day";
goto error;
} else if ((leapDay > 0) && (info->flags & CLF_DAYOFMONTH) && (yyDay != leapDay)) {
leapDay = 0;
}
if ((info->flags & CLF_MONTH)) {
const int *h = hath[IsGregorianLeapYear(&yydate)];
Expand Down Expand Up @@ -3909,19 +3884,15 @@ ClockValidDate(
errMsg = "invalid time (hour)";
errCode = "hour";
goto error;
} else if (yyHour == 24) {
leapDay = 0;
}
/* minutes */
if (yyMinutes < 0 || yyMinutes > 59 || (yyMinutes && (yyHour == 24))) {
errMsg = "invalid time (minutes)";
errCode = "minutes";
goto error;
} else if ((yyMinutes % 15) != 14) {
leapDay = 0;
}
/* oldscan could return secondOfDay (parsedTime) -1 by invalid time (ex.: 25:00:00) */
if (yySeconds < 0 || yySeconds > (leapDay ? 60 : 59) || yySecondOfDay <= -1 || (yySeconds && (yyHour == 24))) {
if (yySeconds < 0 || yySeconds > 59 || yySecondOfDay <= -1 || (yySeconds && (yyHour == 24))) {
errMsg = "invalid time";
errCode = "seconds";
goto error;
Expand Down
9 changes: 4 additions & 5 deletions tests/clock.test
Original file line number Diff line number Diff line change
Expand Up @@ -38461,9 +38461,8 @@ test clock-68.1 {Leap second, minute, hour [f2b5f89c0d], regression test (no val
test clock-68.1a {Leap second, minute, hour [f2b5f89c0d], regression test (validity check)} -body {
set res {}
foreach {d i} {
"2012-06-30 23:59:60" 1341100800
"2012-06-30 24:00:00" 1341100800
} {
} {
# check with free scan:
if {[set t [clock scan $d -gmt 1]] != $i} {
lappend res "free-scan \"$d\" == $t, expected $i"
Expand All @@ -38475,9 +38474,8 @@ test clock-68.1a {Leap second, minute, hour [f2b5f89c0d], regression test (valid
}
set res; # must be empty
} -result {}
test clock-68.2 {Leap second, minute, hour [f2b5f89c0d], regression test (validity check)} -constraints !valid_off -body {
# regardless solution for [f2b5f89c0d], this conversions must fail on -valid 1 (constraints !valid_off),
# because of wrong day and month for the leap second. There were only leap seconds from 1972 - 2016:
test clock-68.2 {Leap second, "24:00", regression test (validity check)} -constraints !valid_off -body {
# Leap seconds are not supported. "24:00" is supported.
set res {}
foreach {d i} {
"2012-06-29 23:59:60" "invalid time"
Expand All @@ -38486,6 +38484,7 @@ test clock-68.2 {Leap second, minute, hour [f2b5f89c0d], regression test (validi
"2012-05-30 24:00:01" "invalid time"
"2012-05-30 24:01:00" "invalid time"
"1971-06-30 23:59:60" "invalid time"
"2012-06-30 23:59:60" "invalid time"
"2018-06-30 23:59:60" "invalid time"
} {
# check with free scan:
Expand Down

0 comments on commit dc77560

Please sign in to comment.