[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Time bug?

hengist podd

10/15/2006 10:23:00 PM

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

3 Answers

Yukihiro Matsumoto

10/15/2006 11:17:00 PM

0

Hi,

In message "Re: Time bug?"
on Mon, 16 Oct 2006 07:25:14 +0900, "has" <has.temp3@virgin.net> 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.

hengist podd

10/16/2006 6:06:00 PM

0


Yukihiro Matsumoto 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?

Yukihiro Matsumoto

10/18/2006 2:48:00 AM

0

Hi,

In message "Re: Time bug?"
on Tue, 17 Oct 2006 03:10:16 +0900, "has" <has.temp3@virgin.net> writes:

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

NUM2LL() and LL2NUM() respectively.

matz.