Tk Library Source Code
View Ticket
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Ticket UUID: c800a75eb5cecd208e2e48bbe46226aec4a70c04
Title: [clock scan] bug in widget::calendar (Tcl 9)
Type: Bug Version: trunk
Submitter: emiliano Created on: 2025-11-05 14:22:37
Subsystem: tklib :: widget Assigned To: aku
Priority: 5 Medium Severity: Critical
Status: Closed Last Modified: 2025-11-07 15:15:17
Resolution: Fixed Closed By: emiliano
    Closed on: 2025-11-07 15:15:17
Description:
When navegating the [widget::calendar] widget by month (small triangle on the right) the following error occurs when transitioning from december/$year to january/[incr year]:

unable to convert input string: invalid month
unable to convert input string: invalid month
    while executing
"clock scan "[incr month]/1/$year	1 day ago""
    (procedure "::widget::calendar::Snit_methodnumberofdays" line 8)
    invoked from within
"$self numberofdays $data(month) $data(year)"
    (procedure "::widget::calendar::Snit_methodadjust" line 44)
    invoked from within
".f adjust 0 1 0"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 [linsert $args 0 $self]"
    invoked from within
"::snit::RT.CallInstance ::widget::calendar::Snit_inst1 adjust 0 1 0"
    (command bound to event)

The problem is the validating nature (by default) of the [clock scan] command in Tcl 9
User Comments: emiliano added on 2025-11-07 15:15:17:
Attached a second patch (to be applied over the first one) which I hope makes things clearer. The code calls the numberofdays method with a range of months from 0 (meaning december last year) to 13 (january next year).

There's no need to go round trip to [clock scan]/[clock format] just to determine the number of days in month for the pair month/year, as this can be determined by a simple lookup table. As an additional benefit, the code should be way faster on 8.X (not that it matters in this use case).

Manually tested with both 8.6 and 9.1

oehhar added on 2025-11-07 08:36:03:

Mark has tested the patch and approved it. Closing.


oehhar added on 2025-11-07 08:35:21:

Fix committed by commit [b4639f860b].

Thanks to Mark Summerfield for the report and Emiliano for the great fix.

Take care, Harald


emiliano added on 2025-11-05 14:25:51:
Attached patch solves the issue.

Attachments: