diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | library/clock.tcl | 41 | ||||
-rw-r--r-- | tests/clock.test | 41 |
3 files changed, 67 insertions, 20 deletions
@@ -5,6 +5,11 @@ that results in 32- and 64-bit integer results, avoiding calls to wide integer exponentiation routines in this common case. [Bug 1767293] + + * library/clock.tcl (ParseClockScanFormat): Modified code to allow + * tests/clock.test (clock-60.*): case-insensitive + matching of time zone and month names. [Bug 1781282] + 2007-08-24 Don Porter <dgp@users.sourceforge.net> diff --git a/library/clock.tcl b/library/clock.tcl index dfc5d73..fcce1b4 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.tcl,v 1.43 2007/04/20 02:23:31 kennykb Exp $ +# RCS: @(#) $Id: clock.tcl,v 1.44 2007/08/25 16:53:25 kennykb Exp $ # #---------------------------------------------------------------------- @@ -1643,16 +1643,16 @@ proc ::tcl::clock::ParseClockScanFormat {formatString locale} { i {7 1 2 3 4 5 6} \ abr [mc DAYS_OF_WEEK_ABBREV] \ full [mc DAYS_OF_WEEK_FULL] { - dict set l $abr $i - dict set l $full $i + dict set l [string tolower $abr] $i + dict set l [string tolower $full] $i incr i } foreach { regex lookup } [UniquePrefixRegexp $l] break append re ( $regex ) dict set fieldSet dayOfWeek [incr fieldCount] append postcode "dict set date dayOfWeek \[" \ - "dict get " [list $lookup] " \$field" \ - [incr captureCount] \ + "dict get " [list $lookup] " " \ + \[ {string tolower $field} [incr captureCount] \] \ "\]\n" } b - B - h { # Name of month @@ -1662,15 +1662,16 @@ proc ::tcl::clock::ParseClockScanFormat {formatString locale} { abr [mc MONTHS_ABBREV] \ full [mc MONTHS_FULL] { incr i - dict set l $abr $i - dict set l $full $i + dict set l [string tolower $abr] $i + dict set l [string tolower $full] $i } foreach { regex lookup } [UniquePrefixRegexp $l] break append re ( $regex ) dict set fieldSet month [incr fieldCount] append postcode "dict set date month \[" \ - "dict get " [list $lookup] " \$field" \ - [incr captureCount] \ + "dict get " [list $lookup] \ + " " \[ {string tolower $field} \ + [incr captureCount] \] \ "\]\n" } C { # Gregorian century @@ -1761,7 +1762,8 @@ proc ::tcl::clock::ParseClockScanFormat {formatString locale} { set state %O } p - P { # AM/PM indicator - set l [list [mc AM] 0 [mc PM] 1] + set l [list [string tolower [mc AM]] 0 \ + [string tolower [mc PM]] 1] foreach { regex lookup } [UniquePrefixRegexp $l] break append re ( $regex ) dict set fieldSet amPmIndicator [incr fieldCount] @@ -1889,25 +1891,26 @@ proc ::tcl::clock::ParseClockScanFormat {formatString locale} { set d {} foreach triple [mc LOCALE_ERAS] { foreach {t symbol year} $triple break - dict set d $symbol $year + dict set d [string tolower $symbol] $year } foreach { regex lookup } [UniquePrefixRegexp $d] break append re (?: $regex ) } E { set l {} - dict set l [mc BCE] BCE - dict set l [mc CE] CE - dict set l B.C.E. BCE - dict set l C.E. CE - dict set l B.C. BCE - dict set l A.D. CE + dict set l [string tolower [mc BCE]] BCE + dict set l [string tolower [mc CE]] CE + dict set l b.c.e. BCE + dict set l c.e. CE + dict set l b.c. BCE + dict set l a.d. CE foreach {regex lookup} [UniquePrefixRegexp $l] break append re ( $regex ) dict set fieldSet era [incr fieldCount] append postcode "dict set date era \["\ - "dict get " [list $lookup] " \$field" \ - [incr captureCount] \ + "dict get " [list $lookup] \ + { } \[ {string tolower $field} \ + [incr captureCount] \] \ "\]\n" } y { # Locale-dependent year of the era diff --git a/tests/clock.test b/tests/clock.test index 801cb48..83d624a 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.test,v 1.79 2007/04/20 05:51:11 kennykb Exp $ +# RCS: @(#) $Id: clock.test,v 1.80 2007/08/25 16:53:25 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -36549,6 +36549,45 @@ test clock-59.1 {military time zones} { join $trouble \n } {} +# case-insensitive matching of weekday and month names [Bug 1781282] + +test clock-60.1 {case insensitive weekday names} { + clock scan "2000-W01 monday" -gmt true -format "%G-W%V %a" +} [clock scan "2000-W01-1" -gmt true -format "%G-W%V-%u"] +test clock-60.2 {case insensitive weekday names} { + clock scan "2000-W01 Monday" -gmt true -format "%G-W%V %a" +} [clock scan "2000-W01-1" -gmt true -format "%G-W%V-%u"] +test clock-60.3 {case insensitive weekday names} { + clock scan "2000-W01 MONDAY" -gmt true -format "%G-W%V %a" +} [clock scan "2000-W01-1" -gmt true -format "%G-W%V-%u"] +test clock-60.4 {case insensitive weekday names} { + clock scan "2000-W01 friday" -gmt true -format "%G-W%V %a" +} [clock scan "2000-W01-5" -gmt true -format "%G-W%V-%u"] +test clock-60.5 {case insensitive weekday names} { + clock scan "2000-W01 Friday" -gmt true -format "%G-W%V %a" +} [clock scan "2000-W01-5" -gmt true -format "%G-W%V-%u"] +test clock-60.6 {case insensitive weekday names} { + clock scan "2000-W01 FRIDAY" -gmt true -format "%G-W%V %a" +} [clock scan "2000-W01-5" -gmt true -format "%G-W%V-%u"] +test clock-60.7 {case insensitive month names} { + clock scan "1 january 2000" -gmt true -format "%d %b %Y" +} [clock scan "2000-01-01" -gmt true -format "%Y-%m-%d"] +test clock-60.8 {case insensitive month names} { + clock scan "1 January 2000" -gmt true -format "%d %b %Y" +} [clock scan "2000-01-01" -gmt true -format "%Y-%m-%d"] +test clock-60.9 {case insensitive month names} { + clock scan "1 JANUARY 2000" -gmt true -format "%d %b %Y" +} [clock scan "2000-01-01" -gmt true -format "%Y-%m-%d"] +test clock-60.10 {case insensitive month names} { + clock scan "1 december 2000" -gmt true -format "%d %b %Y" +} [clock scan "2000-12-01" -gmt true -format "%Y-%m-%d"] +test clock-60.11 {case insensitive month names} { + clock scan "1 December 2000" -gmt true -format "%d %b %Y" +} [clock scan "2000-12-01" -gmt true -format "%Y-%m-%d"] +test clock-60.12 {case insensitive month names} { + clock scan "1 DECEMBER 2000" -gmt true -format "%d %b %Y" +} [clock scan "2000-12-01" -gmt true -format "%Y-%m-%d"] + # cleanup namespace delete ::testClock |