Josselin
(Josselin)
1
In my prog, I create a datetime object
d1s = DateTime.civil(2006,6,5,16,00,00)
then later on, I need to create another datetime from this one by adding 1 day and changing the hour to 10:00:00
I can do easily
d1e = d1s + 1
but how can I modify the hour, which stays at 16:00:00 ?
thanks for your help
joss
harp:~ > cat a.rb
ru
require 'date'
require 'yaml'
now = DateTime.now
year, yday = now.year, now.yday
ten_hours = Rational 10, 24
tomorrow = DateTime.ordinal year, yday + 1
ten_oclock_tomorrow = tomorrow + ten_hours
y 'now' => now
y 'ten_oclock_tomorrow' => ten_oclock_tomorrow
harp:~ > ruby a.rb
ยทยทยท
On Fri, 15 Sep 2006, Josselin wrote:
In my prog, I create a datetime object
d1s = DateTime.civil(2006,6,5,16,00,00)
then later on, I need to create another datetime from this one by adding 1 day and changing the hour to 10:00:00
I can do easily
d1e = d1s + 1
but how can I modify the hour, which stays at 16:00:00 ?
thanks for your help
joss
---
now: 2006-09-14T11:01:49-0701
---
ten_oclock_tomorrow: 2006-09-15T10:00:00Z
-a
--
in order to be effective truth must penetrate like an arrow - and that is
likely to hurt. -- wei wu wei