[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

DateTime#+ mystifications

Magnus Bodin

4/12/2005 7:51:00 PM


DateTime objects supports adding, right?

I thought so and tested this:

#######

require 'parsedate'
require 'date'

dates = [
'2005-04-08 10:48:53.577',
'2005-04-08 11:18:53.577',
'2005-04-08 11:48:53.577',
'2005-04-08 12:18:53.577',
'2005-04-08 12:48:53.577',
'2005-04-08 13:18:53.577',
'2005-04-08 13:48:53.577',
'2005-04-08 14:18:53.577',
]

dates.each{ |d|
dp = ParseDate::parsedate(d)
tn = DateTime.new(dp[0],dp[1],dp[2],dp[3],dp[4])
tn = tn + 3600.0/86400.0
print d,"; ",tn.ctime,"\n"
}

############


gives this output

2005-04-08 10:48:53.577; Fri Apr 8 11:48:00 2005
2005-04-08 11:18:53.577; Fri Apr 8 12:17:59 2005
2005-04-08 11:48:53.577; Fri Apr 8 12:47:59 2005
2005-04-08 12:18:53.577; Fri Apr 8 13:18:00 2005
2005-04-08 12:48:53.577; Fri Apr 8 13:47:59 2005
2005-04-08 13:18:53.577; Fri Apr 8 13:17:59 2005
2005-04-08 13:48:53.577; Fri Apr 8 13:48:00 2005
2005-04-08 14:18:53.577; Fri Apr 8 15:17:59 2005

And this does look pretty strange when no time in the
right column seem to start with 14.

-- magnus


1 Answer

Carlos

4/12/2005 8:55:00 PM

0

Magnus Bodin wrote:
[...]

> tn = tn + 3600.0/86400.0
> print d,"; ",tn.ctime,"\n"
>
>
[...]

>2005-04-08 13:18:53.577; Fri Apr 8 13:17:59 2005
>2005-04-08 13:48:53.577; Fri Apr 8 13:48:00 2005
>2005-04-08 14:18:53.577; Fri Apr 8 15:17:59 2005
>
>And this does look pretty strange when no time in the
>right column seem to start with 14.
>
>

Strange. Looks like Daylight Saving Time starting, but I can't find any
place where this happens on 8th April at 14.00...

(It gives the expected output on my machine.)

http://www.timeanddate.com/time/dst...