# Strainge Time Behaviour

**URL:** <https://rubytalk.org/t/strainge-time-behaviour/3535>\
**Category:** ruby-talk\
**Created:** [11 December 2002 17:19 UTC](https://rubytalk.org/t/strainge-time-behaviour/3535 "2002-12-11T17:19:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Travis](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@Travis](https://rubytalk.org/u/Travis)\
**Post date:** [11 December 2002 17:19 UTC](https://rubytalk.org/t/strainge-time-behaviour/3535/1 "2002-12-11T17:19:55Z")

</div>

I’m manipulating some dates, and I just found something weird.

ruby -v  
ruby 1.6.7 (2002-03-01) [i586-mswin32]

# works as expected

irb(main):001:0\> Time.local(2002, 4, 29)  
Mon Apr 29 00:00:00 EDT 2002  
irb(main):002:0\> Time.local(2002, 4, 29) + 86400  
Tue Apr 30 00:00:00 EDT 2002

# weird behaviour

irb(main):004:0\> Time.local(2002, 10, 27)  
Sun Oct 27 00:00:00 EDT 2002  
irb(main):005:0\> Time.local(2002, 10, 27) + 86400  
Sun Oct 27 23:00:00 EST 2002

So, adding the amount of seconds to equal one day to 10/27/2002 only  
brings it up to 23:00. If this is something completely obvious, please  
enlighten me. It’s causing quite a stir in my program…

Sincerely,  
Travis Whitton [whitton@atlantic.net](mailto:whitton@atlantic.net)

---

<div class="post-metadata">

**Author:** ![Paul\_E.C\_Melis](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@Paul\_E.C\_Melis](https://rubytalk.org/u/Paul_E.C_Melis)\
**Post date:** [11 December 2002 17:20 UTC](https://rubytalk.org/t/strainge-time-behaviour/3535/2 "2002-12-11T17:20:00Z")

</div>

> # weird behaviour
> 
> irb(main):004:0\> Time.local(2002, 10, 27)  
> Sun Oct 27 00:00:00 EDT 2002  
> irb(main):005:0\> Time.local(2002, 10, 27) + 86400  
> Sun Oct 27 23:00:00 EST 2002

Note the difference in type of time returned: EDT vs. EST  
The first is Eastern Daylight (savings) Time, the second is Eastern Standard  
Time, that should explain the difference of 1 hour.

But it’s strange of course, it should return the same types regardless.

Paul

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard1](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Ara.T.Howard1](https://rubytalk.org/u/Ara.T.Howard1)\
**Post date:** [11 December 2002 17:40 UTC](https://rubytalk.org/t/strainge-time-behaviour/3535/3 "2002-12-11T17:40:05Z")

</div>

[snip]

> I’m manipulating some dates, and I just found something weird.  
> [snip]

and even weirder :

~ \> irb  
irb(main):001:0\> t = Time.local(2002, 10, 27)  
Sun Oct 27 00:00:00 MDT 2002  
irb(main):002:0\> 24.times do |h|  
irb(main):003:1\* p t + 3600 \* h  
irb(main):004:1\> end  
Sun Oct 27 00:00:00 MDT 2002  
Sun Oct 27 01:00:00 MDT 2002  
Sun Oct 27 01:00:00 MST 2002  
Sun Oct 27 02:00:00 MST 2002  
Sun Oct 27 03:00:00 MST 2002  
Sun Oct 27 04:00:00 MST 2002  
Sun Oct 27 05:00:00 MST 2002  
Sun Oct 27 06:00:00 MST 2002  
Sun Oct 27 07:00:00 MST 2002  
Sun Oct 27 08:00:00 MST 2002  
Sun Oct 27 09:00:00 MST 2002  
Sun Oct 27 10:00:00 MST 2002  
Sun Oct 27 11:00:00 MST 2002  
Sun Oct 27 12:00:00 MST 2002  
Sun Oct 27 13:00:00 MST 2002  
Sun Oct 27 14:00:00 MST 2002  
Sun Oct 27 15:00:00 MST 2002  
Sun Oct 27 16:00:00 MST 2002  
Sun Oct 27 17:00:00 MST 2002  
Sun Oct 27 18:00:00 MST 2002  
Sun Oct 27 19:00:00 MST 2002  
Sun Oct 27 20:00:00 MST 2002  
Sun Oct 27 21:00:00 MST 2002  
Sun Oct 27 22:00:00 MST 2002  
24

irb(main):005:0\> p t + 3600 \* 1  
Sun Oct 27 01:00:00 MDT 2002  
nil

irb(main):006:0\> p t + 3600 \* 2  
Sun Oct 27 01:00:00 MST 2002  
nil

irb(main):007:0\> p t + 3600  
Sun Oct 27 01:00:00 MDT 2002  
nil

irb(main):008:0\> p t + 7200  
Sun Oct 27 01:00:00 MST 2002  
nil

this looks like a bug!

-a

> **···**
>
> On 11 Dec 2002, Travis Whitton wrote:
> 
> –
> 
> ====================================
> 
> > Ara Howard  
> > NOAA Forecast Systems Laboratory  
> > Information and Technology Services  
> > Data Systems Group  
> > R/FST 325 Broadway  
> > Boulder, CO 80305-3328  
> > Email: [ahoward@fsl.noaa.gov](mailto:ahoward@fsl.noaa.gov)  
> > Phone: 303-497-7238  
> > Fax: 303-497-7259  
> > ====================================  
> > SIGSIG – signature too long (core dumped)

---

<div class="post-metadata">

**Author:** ![Alexander\_Bokovoy](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@Alexander\_Bokovoy](https://rubytalk.org/u/Alexander_Bokovoy)\
**Post date:** [11 December 2002 18:05 UTC](https://rubytalk.org/t/strainge-time-behaviour/3535/4 "2002-12-11T18:05:42Z")

</div>

Day Light savings turnover?

> **···**
>
> On Thu, Dec 12, 2002 at 02:19:55AM +0900, Travis Whitton wrote:
> 
> > I’m manipulating some dates, and I just found something weird.
> > 
> > ruby -v  
> > ruby 1.6.7 (2002-03-01) [i586-mswin32]
> > 
> > # works as expected
> > 
> > irb(main):001:0\> Time.local(2002, 4, 29)  
> > Mon Apr 29 00:00:00 EDT 2002  
> > irb(main):002:0\> Time.local(2002, 4, 29) + 86400  
> > Tue Apr 30 00:00:00 EDT 2002
> > 
> > # weird behaviour
> > 
> > irb(main):004:0\> Time.local(2002, 10, 27)  
> > Sun Oct 27 00:00:00 EDT 2002  
> > irb(main):005:0\> Time.local(2002, 10, 27) + 86400  
> > Sun Oct 27 23:00:00 EST 2002
> > 
> > So, adding the amount of seconds to equal one day to 10/27/2002 only  
> > brings it up to 23:00. If this is something completely obvious, please  
> > enlighten me. It’s causing quite a stir in my program…  
> > –  
> > / Alexander Bokovoy
> 
> * * *
> 
> As a computer, I find your faith in technology amusing.

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard1](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Ara.T.Howard1](https://rubytalk.org/u/Ara.T.Howard1)\
**Post date:** [11 December 2002 17:40 UTC](https://rubytalk.org/t/strainge-time-behaviour/3535/5 "2002-12-11T17:40:09Z")

</div>

[snip]

i guess maybe daylight savings time takes effect at 1:59 am, though that  
suprised me… i always assumed 00:00

-a

> **···**
>
> On Wed, 11 Dec 2002, ahoward wrote:
> 
> > On 11 Dec 2002, Travis Whitton wrote:
> > 
> > [snip]
> > 
> > > I’m manipulating some dates, and I just found something weird.  
> > > [snip]
> > 
> > and even weirder :  
> > –
> 
> ====================================
> 
> > Ara Howard  
> > NOAA Forecast Systems Laboratory  
> > Information and Technology Services  
> > Data Systems Group  
> > R/FST 325 Broadway  
> > Boulder, CO 80305-3328  
> > Email: [ahoward@fsl.noaa.gov](mailto:ahoward@fsl.noaa.gov)  
> > Phone: 303-497-7238  
> > Fax: 303-497-7259  
> > ====================================  
> > SIGSIG – signature too long (core dumped)

---

<div class="post-metadata">

**Author:** ![David\_Alan\_Black1](https://avatars.discourse-cdn.com/v4/letter/d/278dde/32.png) [@David\_Alan\_Black1](https://rubytalk.org/u/David_Alan_Black1)\
**Post date:** [11 December 2002 17:48 UTC](https://rubytalk.org/t/strainge-time-behaviour/3535/6 "2002-12-11T17:48:41Z")

</div>

Hi –

> [snip]
> 
> > I’m manipulating some dates, and I just found something weird.  
> > [snip]
> 
> and even weirder :
> 
> ~ \> irb  
> irb(main):001:0\> t = Time.local(2002, 10, 27)  
> Sun Oct 27 00:00:00 MDT 2002  
> irb(main):002:0\> 24.times do |h|  
> irb(main):003:1\* p t + 3600 \* h  
> irb(main):004:1\> end  
> Sun Oct 27 00:00:00 MDT 2002  
> Sun Oct 27 01:00:00 MDT 2002  
> Sun Oct 27 01:00:00 MST 2002  
> Sun Oct 27 02:00:00 MST 2002  
> Sun Oct 27 03:00:00 MST 2002  
> […]
> 
> irb(main):005:0\> p t + 3600 \* 1  
> Sun Oct 27 01:00:00 MDT 2002  
> nil
> 
> irb(main):006:0\> p t + 3600 \* 2  
> Sun Oct 27 01:00:00 MST 2002  
> nil
> 
> irb(main):007:0\> p t + 3600  
> Sun Oct 27 01:00:00 MDT 2002  
> nil
> 
> irb(main):008:0\> p t + 7200  
> Sun Oct 27 01:00:00 MST 2002  
> nil
> 
> this looks like a bug!

I’m probably being completely thick, but what part of this  
looks bug-like?

David

> **···**
>
> On Thu, 12 Dec 2002, ahoward wrote:
> 
> > On 11 Dec 2002, Travis Whitton wrote:
> 
> –  
> David Alan Black  
> home: [dblack@candle.superlink.net](mailto:dblack@candle.superlink.net)  
> work: blackdav@shu.edu  
> Web: [http://pirate.shu.edu/~blackdav](http://pirate.shu.edu/~blackdav)

---

<div class="post-metadata">

**Author:** ![Chris18](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@Chris18](https://rubytalk.org/u/Chris18)\
**Post date:** [11 December 2002 18:33 UTC](https://rubytalk.org/t/strainge-time-behaviour/3535/7 "2002-12-11T18:33:47Z")

</div>

[snip]

i guess maybe daylight savings time takes effect at 1:59 am, though that  
suprised me… i always assumed 00:00

> **···**
>
> ----- Original Message -----  
> From: “ahoward” [ahoward@fsl.noaa.gov](mailto:ahoward@fsl.noaa.gov)
> 
> * * *
> 
> Well, I think it happens _at_ 2:00 am (not 1:59). Ruby’s got it right.
> 
> Chris

---

<div class="post-metadata">

**Author:** ![Michael\_Campbell1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_Campbell1](https://rubytalk.org/u/Michael_Campbell1)\
**Post date:** [11 December 2002 19:15 UTC](https://rubytalk.org/t/strainge-time-behaviour/3535/8 "2002-12-11T19:15:38Z")

</div>

> i guess maybe daylight savings time takes effect at 1:59 am, though that  
> suprised me… i always assumed 00:00

I thought it was 2:00 am.
