Time's dst? strangeness

C

Chris Shea

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).)
 
R

Rick DeNatale

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.
 

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
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top