# Time bug?

**URL:** <https://www.ruby-forum.com/t/time-bug/72245>\
**Category:** Ruby\
**Created:** [October 16, 2006, 12:25am UTC](https://www.ruby-forum.com/t/time-bug/72245 "2006-10-16T00:25:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![has](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/da6949/32.png) [@has](https://www.ruby-forum.com/u/has)\
**Post date:** [October 16, 2006, 12:25am UTC](https://www.ruby-forum.com/t/time-bug/72245/1 "2006-10-16T00:25:24Z")

</div>

I’m trying to figure out how Ruby’s Time class deals with timezones and  
standard/summer time, and noticed the following inconsistency (second  
one down):

t = Time.local(2006, 3, 26, 0, 59, 59) # winter  
p [t.isdst, t] # [false, Sun Mar 26 00:59:59 GMT 2006]

t = Time.local(2006, 3, 26, 1, 0, 0) # summer  
p [t.isdst, t] # [true, Sun Mar 26 02:00:00 BST 2006] # why not  
01:00:00???

t = Time.local(2006, 3, 26, 2, 0, 0) # summer  
p [t.isdst, t] # [true, Sun Mar 26 02:00:00 BST 2006]

t = Time.local(2006, 10, 29, 0, 12, 31) # summer  
p [t.isdst, t] # [true, Sun Oct 29 00:12:31 BST 2006]

t = Time.local(2006, 10, 29, 1, 12, 31) # summer  
p [t.isdst, t] # [true, Sun Oct 29 01:12:31 BST 2006]

t = Time.local(2006, 10, 29, 1, 12, 32) # winter  
p [t.isdst, t] # [false, Sun Oct 29 01:12:32 GMT 2006]

t = Time.local(2006, 10, 29, 2, 10, 32) # winter  
p [t.isdst, t] # [false, Sun Oct 29 02:10:32 GMT 2006]

Is this a bug? (If not, what’s the explanation for it?)

Thanks

---

<div class="post-metadata">

**Author:** ![has](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/da6949/32.png) [@has](https://www.ruby-forum.com/u/has)\
**Post date:** [October 16, 2006, 1:17am UTC](https://www.ruby-forum.com/t/time-bug/72245/2 "2006-10-16T01:17:34Z")

</div>

Hi,

In message “Re: Time bug?”  
on Mon, 16 Oct 2006 07:25:14 +0900, “has” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
writes:

|I’m trying to figure out how Ruby’s Time class deals with timezones and  
|standard/summer time, and noticed the following inconsistency (second  
|one down):  
|  
|t = Time.local(2006, 3, 26, 0, 59, 59) # winter  
|p [t.isdst, t] # [false, Sun Mar 26 00:59:59 GMT 2006]  
|  
|t = Time.local(2006, 3, 26, 1, 0, 0) # summer  
|p [t.isdst, t] # [true, Sun Mar 26 02:00:00 BST 2006] # why not 01:00:00???

Because Sun Mar 26 01:00:00 BST 2006 does not exist because of DST  
shifting.

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![has](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/da6949/32.png) [@has](https://www.ruby-forum.com/u/has)\
**Post date:** [October 16, 2006, 8:13pm UTC](https://www.ruby-forum.com/t/time-bug/72245/3 "2006-10-16T20:13:38Z")

</div>

Yukihiro M. wrote:

> |t = Time.local(2006, 3, 26, 1, 0, 0) # summer  
> |p [t.isdst, t] # [true, Sun Mar 26 02:00:00 BST 2006] # why not 01:00:00???
> 
> Because Sun Mar 26 01:00:00 BST 2006 does not exist because of DST  
> shifting.

[slaps self] Ah, of course. So obvious. This is what happens when one  
tries to bridge Ruby’s very nice Time class with Mac OS’s rather  
horrible LongDateTime type without enough sleep.😉

I guess I was just thrown by Time automatically adjusting the invalid  
input, rather than just throwing an error. But I see why there might be  
a justification for doing it that way.

Many thanks,

has

p.s. What’s the recommended method for converting BigNums to long long  
and vice-versa in C?

---

<div class="post-metadata">

**Author:** ![has](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/da6949/32.png) [@has](https://www.ruby-forum.com/u/has)\
**Post date:** [October 18, 2006, 4:49am UTC](https://www.ruby-forum.com/t/time-bug/72245/4 "2006-10-18T04:49:24Z")

</div>

Hi,

In message “Re: Time bug?”  
on Tue, 17 Oct 2006 03:10:16 +0900, “has” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
writes:

|p.s. What’s the recommended method for converting BigNums to long long  
|and vice-versa in C?

NUM2LL() and LL2NUM() respectively.

```
						matz.

```
