#3446 clock format %W broken

obsolete: 8.5a5
closed-fixed
5
2006-07-30
2006-06-13
Neil Madden
No

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.

Discussion

  • Neil Madden

    Neil Madden - 2006-06-13

    Patch to fix %W format error in library/clock.tcl

     
    Attachments
  • Neil Madden

    Neil Madden - 2006-06-13
    • assigned_to: dkf --> kennykb
     
  • Donal K. Fellows

    • labels: 105657 --> 06. Time Measurement
     
  • Joe Mistachkin

    Joe Mistachkin - 2006-06-13

    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"

     
  • Kevin B KENNY

    Kevin B KENNY - 2006-07-30
    • status: open --> closed-fixed
     
  • Kevin B KENNY

    Kevin B KENNY - 2006-07-30

    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.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks