Time bug?

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

Hi,

In message “Re: Time bug?”
on Mon, 16 Oct 2006 07:25:14 +0900, “has” [email protected]
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.

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.:wink:

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?

Hi,

In message “Re: Time bug?”
on Tue, 17 Oct 2006 03:10:16 +0900, “has” [email protected]
writes:

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

NUM2LL() and LL2NUM() respectively.

						matz.