- This topic has 3 replies, 3 voices, and was last updated 19 years, 3 months ago by .
-
Topic
-
I have a tcl that calculates age for one of our systems. One of the tests is to find out whether the person has had a birthday yet this year. I am converting the birthday to julian dates and subtracting. I found an interesting problem today…. The tcl has a problem with converting the birthday 2/29 to a julian date in a non-leap year. I am enclosing the portion of code that is not working in hopes that someone has a suggestion! When the brday came out to 2/29, I get a Tcl callout error {unable to convert date-time string “2/29”}
#### Get four digit year of birth, month and day, omitting leading zeros
set byear [string range $dob 0 3]
if {[string range $dob 4 4] == “0”} {
set bmonth [string range $dob 5 5]
} else {set bmonth [string range $dob 4 5]}
if {[string range $dob 6 6] == “0”} {
set bday [string range $dob 7 7]
} else {set bday [string range $dob 6 7]}
set brday $bmonth/$bday
set rbjday [clock format [clock scan $brday] -format %j]
set bjday [string trimleft $rbjday 0]
#### Have they had a birthday yet this year?
set ageDays [expr $day – $bday]
set ageMonths [expr $month – $bmonth]
set ageYears [expr $year – $byear]
if {$ageDays < 0} {set ageMonths [expr $ageMonths - 1]} if {$ageMonths < 0} {set ageYears [expr $ageYears - 1]} Thanks! Kathy
- The forum ‘Cloverleaf’ is closed to new topics and replies.