Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-02-10
22:33 • Ticket [1120012fff] clock scan accepts bogus dates status still Closed with ... artifact: c2bac2439e user: kennykb
22:33 • Ticket [1120012fff]: 4 changes artifact: 165702d966 user: kennykb
22:33 • Add attachment daysinmonth.tcl to ticket [1120012fff] artifact: 6e1c23f82e user: kennykb
22:14 • Ticket [1120012fff] clock scan accepts bogus dates status still Closed with ... artifact: becde2ae51 user: kennykb
22:13 • Ticket [1120012fff]: 2 changes artifact: 47bf78186e user: kennykb
22:13 • Ticket [1120012fff]: 5 changes artifact: 15515a4dc9 user: kennykb
22:13 • Closed ticket [1120012fff]. artifact: 03995a44ec user: kennykb
21:12 • Ticket [1120012fff]: 4 changes artifact: d7b4d388bd user: coldstore
13:10 • New ticket [1120012fff]. artifact: 3f37db05ea user: coldstore

clock scan accepts bogus dates

Closed / Invalid1120012fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2005-02-10 13:10:55
clock scan accepts fairly wild dates, such as the 99th
of February 2005, but rejects the 100th of February ...
I haven't tried this on a leap year :)

I would expect it to error on such dates.

% clock scan 2005/02/99 -format %Y/%m/%d
1115647200
% clock scan 2005/02/100 -format %Y/%m/%d
input string does not match supplied format
% puts $tcl_version
8.5
% puts $tcl_patchLevel
8.5a2
coldstoreplain2005-02-10 21:12:35
Logged In: YES 
user_id=19214

I only discovered this behavior because I was relying on
[clock scan]'s error to construct a calendar.

I was iterating over day and scanning $day/$month/$year
until it errored saved me having to remember how many days
in each month, correcting for leap years and centuries.
kennykb Closed ticket [1120012fff]. [History diff]2005-02-10 22:13:57
kennykbplain2005-02-10 22:13:58
Logged In: YES 
user_id=99768

This behavior is by design; [clock scan] 
will accept any number that matches the 
format group, even if it is outside the range.
This is actually useful on occasion.  In fact,
one of the ways to determine the number
of days in a month is to give [clock scan]
day zero of the following month (which might
be month thirteen).  The attached file gives
the idea.
kennykb Ticket [1120012fff]: 2 changes [History diff]2005-02-10 22:13:59
kennykbplain2005-02-10 22:14:02
File Added - 119462: daysinmonth.tcl
kennykbplain2005-02-10 22:33:24
File Added - 119467: daysinmonth.tcl

Logged In: YES 
user_id=99768

A more obvious method to find the last 
day of the month in 8.5, by the way, is
to use [clock add], giving it 1 month
-1 day.  I've updated the attachment to
show both methods.
kennykbplain2005-02-10 22:33:25
File Deleted - 119462:
Log in (anonymous is fine) to add a comment.

Attachments: