# Utime: still with bug?

**URL:** <https://www.ruby-forum.com/t/utime-still-with-bug/75415>\
**Category:** Ruby\
**Created:** [March 1, 2006, 8:48pm UTC](https://www.ruby-forum.com/t/utime-still-with-bug/75415 "2006-03-01T20:48:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![worldfox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e480ec/32.png) [@worldfox](https://www.ruby-forum.com/u/worldfox)\
**Post date:** [March 1, 2006, 8:48pm UTC](https://www.ruby-forum.com/t/utime-still-with-bug/75415/1 "2006-03-01T20:48:51Z")

</div>

Hello,

with ruby 1.8.4 on Windows XP, there seems still to be an error of 1  
hour when assigning mtime to a file by using utime.

Condition: Assigning a daylight saving time while actual time is not  
daylight saving time.

The same seems to be OK on Windows 98SE.

I tested it as described in:  
  
[http://groups.google.com/group/comp.lang.ruby/browse\_frm/thread/fe4a0](http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/fe4a0)  
342986ebd71

Is there a fix or work-around?

I’m using:  
ruby 1.8.4 (2005-12-24) [i386-mswin32] on both systems.

Axel

---

<div class="post-metadata">

**Author:** ![worldfox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e480ec/32.png) [@worldfox](https://www.ruby-forum.com/u/worldfox)\
**Post date:** [March 2, 2006, 4:47am UTC](https://www.ruby-forum.com/t/utime-still-with-bug/75415/2 "2006-03-02T04:47:10Z")

</div>

Hello.

> I tested it as described in:  
> ruby 1.8.4 (2005-12-24) [i386-mswin32] on both systems.
> 
> Axel

Sorry, this is regression I introduced when fixed another bug of stat(2)  
on WinNT.

# Index: win32.c

RCS file: /src/ruby/win32/win32.c,v  
retrieving revision 1.186  
diff -u -w -b -p -r1.186 win32.c  
— win32.c 24 Feb 2006 02:19:44 -0000 1.186  
+++ win32.c 2 Mar 2006 03:39:48 -0000  
@@ -3223,6 +3223,7 @@ filetime\_to\_unixtime(const FILETIME \*ft)  
tm.tm\_hour = st.wHour;  
tm.tm\_min = st.wMinute;  
tm.tm\_sec = st.wSecond;

- tm.tm\_isdst = -1;  
t = mktime(&tm);  
return t == -1 ? 0 : t;  
}

I’ll commit this on CVS.

---

<div class="post-metadata">

**Author:** ![worldfox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e480ec/32.png) [@worldfox](https://www.ruby-forum.com/u/worldfox)\
**Post date:** [March 2, 2006, 7:34am UTC](https://www.ruby-forum.com/t/utime-still-with-bug/75415/3 "2006-03-02T07:34:57Z")

</div>

> I’ll commit this on CVS.

Thank You! (I’m looking forward to get the “right” utime.)

> [http://search.cpan.org/~shay/Win32-UTCFileTime-](http://search.cpan.org/~shay/Win32-UTCFileTime-)  
> 1.45/lib/Win32/UTCFileTime.pm

_Very_ interesting; and even the presentation of the solution in  
chapter “The Final Solution” and “More problems: utime()”.

Axel
