Tk Library Source Code

View Ticket
Login
Ticket UUID: 1276561
Title: Handling of dates/times
Type: Bug Version: None
Submitter: yaroslav1 Created on: 2005-08-30 12:18:17
Subsystem: mime Assigned To: andreas_kupries
Priority: 7 High Severity:
Status: Closed Last Modified: 2005-10-05 01:48:10
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2005-10-04 18:48:10
Description:
Dates/times are handled incorrectly in tcllib in
non-English locales.
Look at this piece of code from mime.tcl:

--------- piece of code ------
            set gmt [clock format $clock -format "%d %b
%Y %H:%M:%S" \
                           -gmt true]
            if {[set diff [expr {($clock-[clock scan
$gmt])/60}]] < 0} {
                set s -
                set diff [expr {-($diff)}]
            } else {
                set s +
            }
------------------------------
Time in this format doesn't get scanned back into
seconds by clock scan,
because, for example, in Russian locale (ru_RU.KOI8-R)
in looks like:

30 <unicode string> 2005 11:32:07

Unicode string here transcribes as "avgust" which is
russian name for
August. So Tcl error "unable to convert date-time
string" appears.
I suggest to replace it with something like:

            set gmt [clock format $clock -format
"%Y-%m-%d %H:%M:%S" \
                           -gmt true]

Also I suggest to check in other such places (use of
clock format / clock scan) in tcllib's code.
User Comments: andreas_kupries added on 2005-10-05 01:48:10:
Logged In: YES 
user_id=75003

Accepted the patch, applied to CVS Head.

andreas_kupries added on 2005-10-05 01:15:05:

File Added - 151258: 1312869_mime.patch

andreas_kupries added on 2005-10-05 01:15:04:
Logged In: YES 
user_id=75003

Adding the patch file from the patch entry. It is not clear
to me why asnother entry was opened. Files/patches can be
attached everywhere.

cc_benny added on 2005-10-04 20:18:53:
Logged In: YES 
user_id=143885

Ah, I see that the OP already mentioned this kind 
of patch. 
 
There are more problems though, because the 
formatting part of "parsedatetime proper" is also 
broken. 
 
I have posted a patch on the patch tracker as 
#1312869. 
 
Note: I see that the same bug has been reported 
as #911580 in 2004.

cc_benny added on 2005-10-04 19:49:03:
Logged In: YES 
user_id=143885

I get the same problem here while just sending mail (I am not doing 
anything with dates myself).  Smtp.tcl calls 
 
  parsedatetime -now proper 
 
and that throws an error, just because I am on de_DE. There is no 
valid reason for that to happen here, I think. 
 
I don't know if the other parts of parsedatatime are a 
problem or not, they are not used in mime.tcl or smtp.tcl. 
 
I trivial fix for "parsedatetime proper" is to use an ISO-style time 
spec instead: 
 
  set gmt [clock format $clock -format "%Y-%m-%d %H:%M:%S" \ 
                     -gmt true] 
 
This works with 8.4.7 here.

Attachments: