Tcl Source Code

View Ticket
Login
Ticket UUID: b32fffae8156a93d7c083122fdb7e22a10ecf4aa
Title: clock scan returns wrong date if dayOfMonth is missing
Type: Bug Created on: 2015-05-05 09:25:52
Submitter: heinzbr Assigned to: kbk
Subsystem: 06. Time Measurement Severity: Minor
Priority: 5 Medium Last modified: 2015-05-16 05:53:28
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: 8.6.4
Description:
Hello, 
when using 'clock scan' to get the date of a string containing "month" and
"yearOfCentury" today's date is returned instead of assuming "1" for the "dayOfMonth"
and returning the given date.

I think this can be fixed in the DateParseActions table in clock.tcl.

The following two examples show the problem:

set d1 [clock scan "Apr12" -format "%b%y"]
puts [clock format $d1 -format "%d %B %Y"]
#--> result in today's date

set d2 [clock scan "17Apr12" -format "%d%b%y"]
puts [clock format $d2 -format "%d %B %Y"]
#--> 17 April 2012
User Comments:
sebres added on 2015-05-05 09:48:27:
This is undefined behaviour, because scanning of date not completed (not all required date fields fulfilled).

Explanation is simple:

  puts [clock scan "Apr12" -format "%b%y" -base 0 -gmt 1]; # will returns 0

Simple solution does not exists, because I'm sure that 01 as default day would be incorrect. Just use formats always have a days.