Time bug?

H

has

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
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: 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???

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

matz.
 
H

has

Yukihiro said:
|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?
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Time bug?"

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

NUM2LL() and LL2NUM() respectively.

matz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,043
Members
48,769
Latest member
Clifft

Latest Threads

Top