Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: modifying the hour in a datetime object already created
Gavin Kistner
9/14/2006 4:47:00 PM
From: Josselin [mailto:josselin@wanadoo.fr]
> but how can I modify the hour, which stays at 16:00:00 ?
You can't - DateTime objects are immutable. You'd need to create the
DateTime object with the correct time.
It's situations like this which motivated me to make my own MutableTime
class (that internally wraps changing Time objects). I never wrapped it
up as a gem, but you can view the documentation and download it from:
http://phrogz.net/RubyLibs/rdoc/files/MutableTi...
(See the "Full Code" link on that page to download it.)
1 Answer
Josselin
9/14/2006 5:01:00 PM
0
On 2006-09-14 18:46:38 +0200, "Gavin Kistner" <gavin.kistner@anark.com> said:
> From: Josselin [mailto:josselin@wanadoo.fr]
>> but how can I modify the hour, which stays at 16:00:00 ?
>
> You can't - DateTime objects are immutable. You'd need to create the
> DateTime object with the correct time.
>
> It's situations like this which motivated me to make my own MutableTime
> class (that internally wraps changing Time objects). I never wrapped it
> up as a gem, but you can view the documentation and download it from:
>
>
http://phrogz.net/RubyLibs/rdoc/files/MutableTi...
>
> (See the "Full Code" link on that page to download it.)
thanks a lot Gavin... that's a nice trick for me (I'll need to
manipulate dates ...)
I read 'immutable' in the class description, but did not link it to my
problem... tired.. need to break !
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: modifying the hour in a datetime object already created
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password