[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Time's dst? strangeness

Chris Shea

4/11/2007 9:46:00 PM

I've looked at previous threads about dst? and isdst giving incorrect
results, though they seem to hinge upon Daylight Savings Time
information being incorrect, or not updated properly on the OS side.

I think the results I'm finding aren't because of my DST settings
(though I'm unsure how to check). (I doubt, however, that somehow
Apple is shipping computers set to switch back to Standard Time at
1:17:04am on November 4.)

Here's a clear indication of what's happening:

mvb:~ cms$ cat dst.rb
0.upto 10 do |secs|
time = Time.mktime(2007,11,4,1,17,secs)
puts "#{time}: #{time.dst?}"
end

mvb:~ cms$ ruby dst.rb
Sun Nov 04 01:17:00 -0600 2007: true
Sun Nov 04 01:17:01 -0600 2007: true
Sun Nov 04 01:17:02 -0600 2007: true
Sun Nov 04 01:17:03 -0600 2007: true
Sun Nov 04 01:17:04 -0700 2007: false
Sun Nov 04 01:17:05 -0700 2007: false
Sun Nov 04 01:17:06 -0700 2007: false
Sun Nov 04 01:17:07 -0700 2007: false
Sun Nov 04 01:17:08 -0700 2007: false
Sun Nov 04 01:17:09 -0700 2007: false
Sun Nov 04 01:17:10 -0700 2007: false

mvb:~ cms$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]

This also happens if I use Time.local instead of Time.mktime.

This isn't a life-or-death sort of thing. I was talking to my boss
about how DST is usually handled (gracefully). I wanted to whip up a
quick demo, but I was getting strange results and wanted to find the
exact second the results went bad.

Any thoughts?

Chris

(I also tested this on a couple other machines. A Windows box got it
wrong (all false), and two linux boxes got it right (all true).)

1 Answer

Rick DeNatale

4/14/2007 2:30:00 PM

0

On 4/11/07, Chris Shea <cmshea@gmail.com> wrote:
> I've looked at previous threads about dst? and isdst giving incorrect
> results, though they seem to hinge upon Daylight Savings Time
> information being incorrect, or not updated properly on the OS side.
>
> I think the results I'm finding aren't because of my DST settings
> (though I'm unsure how to check). (I doubt, however, that somehow
> Apple is shipping computers set to switch back to Standard Time at
> 1:17:04am on November 4.)

I'm guessing that OS X has the date command, try something like

date -d"Nov 04 01:17:00" +%Z

to see what the OS thinks.


> (I also tested this on a couple other machines. A Windows box got it
> wrong (all false), and two linux boxes got it right (all true).)

Which makes me think that this is probably a problem with the OS.

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denh...