Ticket UUID: | 1120012 | |||
Title: | clock scan accepts bogus dates | |||
Type: | Bug | Version: | None | |
Submitter: | coldstore | Created on: | 2005-02-10 13:10:55 | |
Subsystem: | 06. Time Measurement | Assigned To: | kennykb | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2005-02-10 22:33:25 | |
Resolution: | Invalid | Closed By: | kennykb | |
Closed on: | 2005-02-10 15:13:59 | |||
Description: |
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 | |||
User Comments: |
kennykb added on 2005-02-10 22:33:25:
File Deleted - 119462: kennykb added on 2005-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. kennykb added on 2005-02-10 22:14:02: File Added - 119462: daysinmonth.tcl kennykb added on 2005-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. coldstore added on 2005-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. |
Attachments:
- daysinmonth.tcl [download] added by kennykb on 2005-02-10 22:33:24. [details]