Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-07-31
02:01 • Closed ticket [1505383fff]: clock format %W broken plus 7 other changes artifact: fb6b5728fe user: kennykb
2006-06-14
00:41 • Ticket [1505383fff]: 4 changes artifact: fcc14ad28e user: mistachkin
2006-06-13
20:23 • Ticket [1505383fff]: 1 change artifact: d461949433 user: dkf
19:56 • Ticket [1505383fff]: 1 change artifact: b130d04c90 user: tallniel
19:55 • Ticket [1505383fff]: 4 changes artifact: 5b6f77fe64 user: tallniel
19:55 • Add attachment clockformatW.patch to ticket [1505383fffffffff|1505383ff... artifact: c6e332737f user: tallniel
12:55 • New ticket [1505383fff] clock format %W broken. artifact: b443a31d0f user: tallniel

clock format %W broken

Closed / Fixed1505383fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-06-13 12:55:14
clock format %W option is broken in current CVS:

% info pa
8.5a5
% clock format [clock seconds] -format %W
can't read "Wweeknumber": no such variable
% set errorInfo
can't read "Wweeknumber": no such variable
    while executing
"::format %02d  $Wweeknumber"
    (procedure "::tcl::clock::formatproc'%W'C" line 11)
    invoked from within
"$formatter $clockval $timezone"
    (procedure "::tcl::clock::format" line 74)
    invoked from within
"::tcl::clock::format 1150202323 -format %W"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 [info level 0]"
    (procedure "::tcl::clock::format" line 4)
    invoked from within
"clock format [clock seconds] -format %W"
% info body tcl::clock::formatproc'%W'C

        
                 variable TZData
                 set date [GetDateFields $clockval 
$TZData($timezone)  2299161]
             
                            set WweekNumber  [expr { (
[dict get $date dayOfYear]
                                          - [dict get
$date dayOfWeek]
                                          + 7 ) 
                                        / 7 }]

        return [::format %02d  $Wweeknumber]

The problem is this last reference to $Wweeknumber in
the format: the 'n' should be capitalised. As this is
generated code, the actual bug is in library/clock.tcl
line 4625, proc tcl::clock::ParseClockFormatFormat2. I
attach a patch that fixes this.
tallnielplain2006-06-13 19:55:15
File Added - 181506: clockformatW.patch
tallniel Ticket [1505383fff]: 1 change [History diff]2006-06-13 19:56:06
dkf Ticket [1505383fff]: 1 change [History diff]2006-06-13 20:23:29
mistachkinplain2006-06-14 00:41:08
Logged In: YES 
user_id=113501


I think some of the other format specifiers are also broken
(at least %Ey and %EY):

clock format [clock seconds] -format %Ey
% can't use empty string as operand of "-"
    while executing
"expr { [dict get $date year]
                                         - [lindex $etable
$index 2] }"
    (procedure "GetLocaleEra" line 9)
    invoked from within
"GetLocaleEra  $date[set date {}]  {}"
    (procedure "::tcl::clock::formatproc'%Ey'C" line 6)
    invoked from within
"$formatter $clockval $timezone"
    (procedure "::tcl::clock::format" line 74)
    invoked from within
"clock format [clock seconds] -format %Ey"
kennykbplain2006-07-31 02:01:45
Logged In: YES 
user_id=99768

Joe Mistachkin's comments are a separate bug, which would
get tickled in some combinations of %E without %O.

Neil's analysis of the %W bug is fixed.  (Neil, why on
Earth were you using %W, anyway? The ISO week number is
%V - %W is for compatibility with some legacy software
but is not correct for any known calendar.)

Both bugs are now fixed.
Log in (anonymous is fine) to add a comment.

Attachments: