Forum: Ruby extending a class changes from 1.8.4 to 1.8.6

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
59a7098db47a979d4dd32409c8759ba4?d=identicon&s=25 Tim McIntyre (tmac)
on 2008-10-06 21:10
require 'date'
class MyDateTime < DateTime end

under ruby 1.8.4:
  MyDateTime.now.class -> MyDateTime

under ruby 1.8.6
  MyDateTime.now.class -> DateTime


I feel like I missed the boat on something obvious here.  I googled
around a bit though and didn't see anything and I have a mission
critical issue that I need to resolve.

Thanks in advance!
Tim
59a7098db47a979d4dd32409c8759ba4?d=identicon&s=25 Tim McIntyre (tmac)
on 2008-10-06 21:17
Tim McIntyre wrote:
> require 'date'
> class MyDateTime < DateTime end
>
> under ruby 1.8.4:
>   MyDateTime.now.class -> MyDateTime
>
> under ruby 1.8.6
>   MyDateTime.now.class -> DateTime
>
>
> I feel like I missed the boat on something obvious here.  I googled
> around a bit though and didn't see anything and I have a mission
> critical issue that I need to resolve.
>
> Thanks in advance!
> Tim

I suppose I should actually ask a question with that:-)

What do I need to do to get the 1.8.4 behavior in 1.8.6?

Thanks!
Tim
97550977337c9f0a0e1a9553e55bfaa0?d=identicon&s=25 Jano Svitok (Guest)
on 2008-10-06 21:25
(Received via mailing list)
On Mon, Oct 6, 2008 at 21:15, Tim McIntyre <tmac@easystreet.com> wrote:
>>
>
> Thanks!
> Tim

I suggest looking at lib/date.rb, particularly at Date.now and
Time.now.to_datetime. The rest might depend on your usage.
This topic is locked and can not be replied to.