Tcl Source Code

View Ticket
Login
Ticket UUID: 926106
Title: file stat -> ctime is summertime dependant
Type: Bug Created on: 2004-03-30 16:25:01
Submitter: tommesch Assigned to: kennykb
Subsystem: 37. File System Severity:
Priority: 7 High Last modified: 2004-11-02 00:00:12
Status: Closed Closed by: kennykb
Resolution: Accepted Closed on: 2004-11-01 17:00:12
Version: obsolete: 8.5a2
Description:
Tcl version: 8.4.5
System: Win2k/WinXP

If I do a stat on "c:\programs" the element ctime in
stat array  depends on the month i do the stat call.

If I do at march 1st:

file stat "c:\programs" stat
puts $stat(ctime)

I get a 3600 different result I as do that a may 1st.
One can simply check that by setting system date 2
monthes back and repeat the test.
User Comments:
vincentdarley added on 2004-03-31 05:54:24:
Logged In: YES 
user_id=32170

I know nothing about such clock issues, assigning to someone
who might...

kennykb added on 2004-04-08 20:34:27:
Logged In: YES 
user_id=99768

Vince,

'stat' and '__stat64' on Winodws are broken by design.
The behavior that the original poster reports is documented
in http://support.microsoft.com/?kbid=190315

Since the referenced page characterizes the misfeature
pretty well, we can probably figure out how to undo the
damage.  Don't you love programming around Microsoft?

vincentdarley added on 2004-04-19 23:37:46:
Logged In: YES 
user_id=32170

You can find the volume type (NTFS or not) through the code
in tclWinFile.c:TclpFilesystemPathType(), but beyond that
fixing this is beyond me (no knowledge of timezone/locale
issues), so if someone wants this fixed, please provide a patch.

vincentdarley added on 2004-09-28 22:39:57:
Logged In: YES 
user_id=32170

Can any of your recent 'clock' changes be used to do
something about this?

kennykb added on 2004-10-31 09:57:47:
Logged In: YES 
user_id=99768

The 'clock' changes are immaterial - the problem all happens
in ToCTime in tclWinFile.c.  I've committed a fix to the
HEAD. I've not backported it to the 8.4 branch because the
bug has been around for as long as we've supported Windows,
and I'm afraid that there's likely to be legacy code that
depends on it.  I'm also a bit concerned that this will make
[clock format [file mtime $file]] yield a different answer
from Windows Explorer - which has the exact same bug.
Apparently someone in Redmond thinks that's how it's
supposed to work.

vincentdarley added on 2004-11-01 20:19:54:
Logged In: YES 
user_id=32170

The time-reading functions are now ok, but, for example:

# copy $from to $to, but using i/o
set fin [open $from r]
set fout [open $to w]
fcopy $fin $fout
close $fin
close $fout
file mtime $to [file mtime $from]
#end

fails when we're copying across a daylight savings boundary.
('fails' in the sense that the mtime's are different by 1
hour for the 2 files).

vincentdarley added on 2004-11-01 21:57:14:
Logged In: YES 
user_id=32170

Here's a new test for this bug:

test cmdAH-24.12 {Tcl_FileObjCmd: mtime and daylight savings} {
    set name [file join [temporaryDirectory] clockchange]

    file delete -force $name
    close [open $name w]
    set time [clock scan "21:00:00 October 30 2004 GMT"]
    file mtime $name $time
    set newmtime [file mtime $name]
    file delete $name
    expr {$newmtime == $time ? 1 : "$newmtime != $time"}
} {1}

kennykb added on 2004-11-02 00:00:12:
Logged In: YES 
user_id=99768

I might have known that the native 'utime' procedure would
contain a deliberate bug to offset the bug in the native 'stat'.

Now we use neither.

Thanks for the report and the test case.