Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > File.utime, Windows and Ruby 1.8

Reply
Thread Tools

File.utime, Windows and Ruby 1.8

 
 
mike
Guest
Posts: n/a
 
      05-09-2005
The behavior of Fime.utime on Ruby 1.8 on Windows looks wrong:

H:\devel>type test_mtime.rb
time = Time.local(2000, 1, 1, 0, 0, 0)
file = "foo.txt"
File.open(file, "w") {}
File.utime time, time, file
puts time.to_f
puts File.mtime(file).to_f

H:\devel>c:\ruby1.8\bin\ruby.exe -v test_mtime.rb
ruby 1.8.2 (2004-12-25) [i386-mswin32]
946681200.0
946684800.0

The file's mtime is 1 hour later. Using Time.gm doesn't fix the
problem.

Compare with Ruby 1.6, which looks good:
H:\devel>c:\ruby\bin\ruby.exe -v test_mtime.rb
ruby 1.6.7 (2002-03-01) [i386-mingw32]
946681200.0
946681200.0

I don't know if it's related, but I'm using a FAT32 filesystem.


mike

 
Reply With Quote
 
 
 
 
Shad Sterling
Guest
Posts: n/a
 
      05-14-2005
On 5/9/05, mike <(E-Mail Removed)> wrote:
> The behavior of Fime.utime on Ruby 1.8 on Windows looks wrong:

...
> The file's mtime is 1 hour later. Using Time.gm doesn't fix the
> problem.

...
> I don't know if it's related, but I'm using a FAT32 filesystem.
>=20
>=20
> mike
>=20
>=20


I see the same thing, using CIFS to a samba server. I just changed
File.utime in my quirks.rb:

class File
if RUBY_PLATFORM.split("-")[1] =3D=3D "mswin32" then
#puts "fixing win32 File.utime bug"
class << self
alias_method :broken_utime, :utime
def File.utime( atime, mtime, filename )
File.broken_utime( atime, mtime-3600, filename )
end
end
end
end




--=20

----------

Please do not send personal (non-list-related) mail to this address.
Personal mail should be sent to http://www.velocityreviews.com/forums/(E-Mail Removed).


 
Reply With Quote
 
 
 
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      05-15-2005
Hi,

At Mon, 9 May 2005 18:19:34 +0900,
mike wrote in [ruby-talk:141817]:
> H:\devel>c:\ruby1.8\bin\ruby.exe -v test_mtime.rb
> ruby 1.8.2 (2004-12-25) [i386-mswin32]
> 946681200.0
> 946684800.0
>
> The file's mtime is 1 hour later. Using Time.gm doesn't fix the
> problem.


It seems like related to DST.


Index: win32/win32.c
================================================== =================
RCS file: /cvs/ruby/src/ruby/win32/win32.c,v
retrieving revision 1.148
diff -U2 -p -r1.148 win32.c
--- win32/win32.c 14 May 2005 14:57:04 -0000 1.148
+++ win32/win32.c 15 May 2005 00:43:06 -0000
@@ -3491,4 +3491,5 @@ unixtime_to_filetime(time_t time, FILETI
struct tm *tm;
SYSTEMTIME st;
+ FILETIME lt;

tm = gmtime(&time);
@@ -3501,5 +3502,6 @@ unixtime_to_filetime(time_t time, FILETI
st.wSecond = tm->tm_sec;
st.wMilliseconds = 0;
- if (!SystemTimeToFileTime(&st, ft)) {
+ if (!SystemTimeToFileTime(&st, &lt) ||
+ !LocalFileTimeToFileTime(&lt, ft)) {
errno = map_errno(GetLastError());
return -1;


--
Nobu Nakada


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby extension (C++) on OS X [ruby 1.8.2] and Google-Sketchup [ruby 1.8.5] Nicholas Ruby 3 01-28-2007 01:48 AM
The Ruby Edge - Digg for Ruby and Ruby On Rails roschler Ruby 0 10-15-2006 11:35 PM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
Cygwin Ruby and Windows Ruby? cjl Ruby 8 03-20-2005 04:44 AM
PostgreSQL, Ruby, FX Ruby and Windows XP Szymon Drejewicz Ruby 2 09-19-2003 12:59 PM



Advertisments