Tcl Source Code

Check-in [595fad24d7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixed wrong time conversion by free-scan (-1 from ToSecond() caused day decrement) - now the result is the same as for formatted scan, backported from tclclockmod (8.7+); the fix is not really related to [f2b5f89c0d], but since 8.6 doesn't have validity rules, let it make consistent accross all versions. repeat fix [83c5c578cb124286] (without space changes)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | core-8-6-branch
Files: files | file ages | folders
SHA3-256: 595fad24d70e16931576c2f797decdadef19a6ca5fbccd3f5d86dd1e01b16ac8
User & Date: sebres 2024-11-15 17:44:02.111
References
2024-11-21
22:09 Ticket [f2b5f89c0d] clock scan of leapsecond: wrong result in 8.6 and 9.0 status still Open with 3 other changes artifact: 8ecefd73a4 user: sebres
2024-11-15
18:03 Ticket [f2b5f89c0d]: 3 changes artifact: e174d8f70d user: sebres
Context
2024-11-19
09:43
Update "changes" file with bugs fixed so far check-in: 1fad737fe7 user: jan.nijtmans tags: core-8-6-branch
2024-11-15
17:47
merge point (no changes) check-in: 13d4d3d6f2 user: sebres tags: core-8-branch
17:44
fixed wrong time conversion by free-scan (-1 from ToSecond() caused day decrement) - now the result ... check-in: 595fad24d7 user: sebres tags: core-8-6-branch
17:40
revert (too many non-functional space changes by backporting, will be repeated with fixed spaces) check-in: e23ca39647 user: sebres tags: core-8-6-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclDate.c.
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
static time_t
ToSeconds(
    time_t Hours,
    time_t Minutes,
    time_t Seconds,
    MERIDIAN Meridian)
{
    if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) {
	return -1;
    }
    switch (Meridian) {
    case MER24:
	if (Hours < 0 || Hours > 23) {
	    return -1;
	}
	return (Hours * 60L + Minutes) * 60L + Seconds;
    case MERam:
	if (Hours < 1 || Hours > 12) {
	    return -1;
	}
	return ((Hours % 12) * 60L + Minutes) * 60L + Seconds;
    case MERpm:
	if (Hours < 1 || Hours > 12) {
	    return -1;
	}
	return (((Hours % 12) + 12) * 60L + Minutes) * 60L + Seconds;
    }
    return -1;			/* Should never be reached */
}

static int
LookupWord(
    YYSTYPE* yylvalPtr,
    char *buff)
{







<
<
<


<
<
<
|

<
<
<
|

<
<
<
|

|







2513
2514
2515
2516
2517
2518
2519



2520
2521



2522
2523



2524
2525



2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
static time_t
ToSeconds(
    time_t Hours,
    time_t Minutes,
    time_t Seconds,
    MERIDIAN Meridian)
{



    switch (Meridian) {
    case MER24:



	return (Hours * 60 + Minutes) * 60 + Seconds;
    case MERam:



	return ((Hours % 12) * 60 + Minutes) * 60 + Seconds;
    case MERpm:



	return (((Hours % 12) + 12) * 60 + Minutes) * 60 + Seconds;
    }
    return -1;                  /* Should never be reached */
}

static int
LookupWord(
    YYSTYPE* yylvalPtr,
    char *buff)
{
Changes to generic/tclGetDate.y.
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
static time_t
ToSeconds(
    time_t Hours,
    time_t Minutes,
    time_t Seconds,
    MERIDIAN Meridian)
{
    if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) {
	return -1;
    }
    switch (Meridian) {
    case MER24:
	if (Hours < 0 || Hours > 23) {
	    return -1;
	}
	return (Hours * 60L + Minutes) * 60L + Seconds;
    case MERam:
	if (Hours < 1 || Hours > 12) {
	    return -1;
	}
	return ((Hours % 12) * 60L + Minutes) * 60L + Seconds;
    case MERpm:
	if (Hours < 1 || Hours > 12) {
	    return -1;
	}
	return (((Hours % 12) + 12) * 60L + Minutes) * 60L + Seconds;
    }
    return -1;			/* Should never be reached */
}

static int
LookupWord(
    YYSTYPE* yylvalPtr,
    char *buff)
{







<
<
<


<
<
<
|

<
<
<
|

<
<
<
|

|







734
735
736
737
738
739
740



741
742



743
744



745
746



747
748
749
750
751
752
753
754
755
756
static time_t
ToSeconds(
    time_t Hours,
    time_t Minutes,
    time_t Seconds,
    MERIDIAN Meridian)
{



    switch (Meridian) {
    case MER24:



	return (Hours * 60 + Minutes) * 60 + Seconds;
    case MERam:



	return ((Hours % 12) * 60 + Minutes) * 60 + Seconds;
    case MERpm:



	return (((Hours % 12) + 12) * 60 + Minutes) * 60 + Seconds;
    }
    return -1;                  /* Should never be reached */
}

static int
LookupWord(
    YYSTYPE* yylvalPtr,
    char *buff)
{
Changes to tests/clock.test.
36132
36133
36134
36135
36136
36137
36138
36139
36140
36141
36142
36143
36144
36145
36146
	     [clock scan "12:01 pm" -base 0 -gmt 1]
    } -result {60 43260}
test clock-46.6 {freescan: regression test - bad time} \
    -body {
	# 13:00 am/pm are invalid input strings...
	list [clock scan "13:00 am" -base 0 -gmt 1] \
	     [clock scan "13:00 pm" -base 0 -gmt 1]
    } -result {-1 -1}

test clock-46.7 {regression test - switch day by large not-valid time, see bug [3ee8f1c2a785f4d8]} {
    list [clock scan 23:59:59 -base 0 -gmt 1 -format %H:%M:%S] \
	 [clock scan 24:00:00 -base 0 -gmt 1 -format %H:%M:%S] \
	 [clock scan 48:00:00 -base 0 -gmt 1 -format %H:%M:%S]
} {86399 86400 172800}








|







36132
36133
36134
36135
36136
36137
36138
36139
36140
36141
36142
36143
36144
36145
36146
	     [clock scan "12:01 pm" -base 0 -gmt 1]
    } -result {60 43260}
test clock-46.6 {freescan: regression test - bad time} \
    -body {
	# 13:00 am/pm are invalid input strings...
	list [clock scan "13:00 am" -base 0 -gmt 1] \
	     [clock scan "13:00 pm" -base 0 -gmt 1]
    } -result {3600 46800}

test clock-46.7 {regression test - switch day by large not-valid time, see bug [3ee8f1c2a785f4d8]} {
    list [clock scan 23:59:59 -base 0 -gmt 1 -format %H:%M:%S] \
	 [clock scan 24:00:00 -base 0 -gmt 1 -format %H:%M:%S] \
	 [clock scan 48:00:00 -base 0 -gmt 1 -format %H:%M:%S]
} {86399 86400 172800}

37115
37116
37117
37118
37119
37120
37121
37122


37123
37124
37125
37126
37127
37128
37129
37130
37131
37132
37133
37134
37135
37136
37137
37138
37139
37140
37141
37142
37143

37144








37145
37146
37147
37148
37149
37150
37151
37152
37153
37154
37155
37156
    msgcat::mclocale en_uk
    # This will fail without the bug fix, as still de_de is active
    expr {$res == [clock scan "01/01/1970" -locale current -format %x -gmt 1]}
} -cleanup {
    msgcat::mclocale $current
} -result {1}

test clock-68.1 {Leap second [f2b5f89c0d], valid} -constraints knownBug -body {


    clock scan "2012-06-30 23:59:60" -gmt 1
} -result 1341100800
test clock-68.2 {Leap minute [f2b5f89c0d], valid} -constraints knownBug -body {
    clock scan "2012-06-30 23:60:00" -gmt 1
} -result 1341100800
test clock-68.3 {Leap hour [f2b5f89c0d], valid} -constraints knownBug -body {
    clock scan "2012-06-30 24:00:00" -gmt 1
} -result 1341100800
test clock-68.4 {Leap second [f2b5f89c0d], wrong day} -constraints knownBug -body {
    clock scan "2012-06-29 23:59:60" -gmt 1
} -result 1341014400
test clock-68.5 {Leap second [f2b5f89c0d], wrong month} -constraints knownBug -body {
    clock scan "2012-05-30 23:59:60" -gmt 1
} -result 1338422400
test clock-68.6 {Leap second [f2b5f89c0d], minute} -constraints knownBug -body {
    clock scan "2012-05-30 23:60:60" -gmt 1
} -result 1338422460
test clock-68.7 {Leap second [f2b5f89c0d], hour + second} -constraints knownBug -body {
    clock scan "2012-05-30 24:00:60" -gmt 1
} -result 1338422460
test clock-68.8 {Leap second [f2b5f89c0d], hour +  minute} -constraints knownBug -body {

    clock scan "2012-05-30 24:60:00" -gmt 1








} -result 1338426000

# cleanup

namespace delete ::testClock
::tcl::clock::ClearCaches
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End:







|
>
>
|
<
<
|
<
<
|
<
<
|
<
<
|
<
<
|
|
<
|
|
<
>
|
>
>
>
>
>
>
>
>
|











37115
37116
37117
37118
37119
37120
37121
37122
37123
37124
37125


37126


37127


37128


37129


37130
37131

37132
37133

37134
37135
37136
37137
37138
37139
37140
37141
37142
37143
37144
37145
37146
37147
37148
37149
37150
37151
37152
37153
37154
37155
    msgcat::mclocale en_uk
    # This will fail without the bug fix, as still de_de is active
    expr {$res == [clock scan "01/01/1970" -locale current -format %x -gmt 1]}
} -cleanup {
    msgcat::mclocale $current
} -result {1}

test clock-68.1 {Leap second, minute, hour [f2b5f89c0d], regression test (no validity check)} -body {
    set res {}
    foreach {d i} {
	"2012-06-30 23:59:60" 1341100800


	"2012-06-30 23:60:00" 1341100800


	"2012-06-30 24:00:00" 1341100800


	"2012-06-29 23:59:60" 1341014400


	"2012-05-30 23:59:60" 1338422400


	"2012-05-30 23:60:60" 1338422460
	"2012-05-30 24:00:60" 1338422460

	"2012-05-30 24:60:00" 1338426000
    } {

	# check with free scan:
	if {[set t [clock scan $d -gmt 1]] != $i} {
	    lappend res "free-scan \"$d\" == $t, expected $i"
	}
	# check with formatted scan:
	if {[set t [clock scan $d -gmt 1 -format "%Y-%m-%d %H:%M:%S"]] != $i} {
	    lappend res "fmt-scan \"$d\" == $t, expected $i"
	}
    }
    set res; # must be empty
} -result {}

# cleanup

namespace delete ::testClock
::tcl::clock::ClearCaches
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End: