DateTime#+ mystifications

M

Magnus Bodin

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
 
C

Carlos

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/dst2005a.html
 

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

Forum statistics

Threads
474,170
Messages
2,570,925
Members
47,464
Latest member
Bobbylenly

Latest Threads

Top