# Time's dst? strangeness

**URL:** <https://www.ruby-forum.com/t/times-dst-strangeness/91742>\
**Category:** Ruby\
**Created:** [April 11, 2007, 11:50pm UTC](https://www.ruby-forum.com/t/times-dst-strangeness/91742 "2007-04-11T23:50:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [April 11, 2007, 11:50pm UTC](https://www.ruby-forum.com/t/times-dst-strangeness/91742/1 "2007-04-11T23:50:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [April 14, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/times-dst-strangeness/91742/2 "2007-04-14T16:30:32Z")

</div>

On 4/11/07, Chris S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.denhaven2.com/](http://talklikeaduck.denhaven2.com/)
