Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-02-27
09:07 • Closed ticket [1902423fff]: clock format gives wrong result plus 3 other cha... artifact: 7cfe8f9ff3 user: kennykb
2008-02-26
18:55 • New ticket [1902423fff]. artifact: 0a33eb00ee user: gneumann

clock format gives wrong result

Closed / Fixed1902423fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-02-26 18:55:13
clock format returns under certain conditions an incorrect "%T" in the formatted time-string, when "%H:%M:%S" was requested

Example (see result of the 2nd [clock format ...]):

% set s [clock seconds]
1204049747
% set f1 [clock format $s -format "%Y-%m-%d %T"]
2008-02-26 19:15:47
% set f2 [clock format $s -format "%Y-%m-%d %H:%M:%S"]
2008-02-26 %T
% set ::tcl_patchLevel
8.5.1


the used locale is "C".

A quick analysis shows that  ParseClockFormatFormat2 builds an incorrect formatting proc:
===================
proc ::tcl::clock::formatproc'%Y-%m-%d %H:%M:%S'C {clockval timezone} {
        
                 variable TZData
                 set date [GetDateFields $clockval $TZData($timezone)  2299161]
             
        return [::format {%04d-%02d-%02d %%T}  [dict get $date year] [dict get $date month] [dict get $date dayOfMonth]]
}
===================
One can see that for some reasons, %%T was added to the format string. The reason seems to be that 

LocalizeFormat C {%Y-%m-%d %H:%M:%S}
returns {%Y-%m-%d %T}, 

most likely due to a caching bug.
kennykb Closed ticket [1902423fff]. [History diff]2008-02-27 09:07:55
Log in (anonymous is fine) to add a comment.