From: "nobu (Nobuyoshi Nakada)" Date: 2012-06-05T13:36:44+09:00 Subject: [ruby-core:45428] [ruby-trunk - Bug #6547][Assigned] DateTime.new does not call #initialize Issue #6547 has been updated by nobu (Nobuyoshi Nakada). Category set to ext Status changed from Open to Assigned Assignee set to tadf (tadayoshi funaba) Priority changed from Normal to Low It's a standard behavior of Class.new to allocate an instance and call initialize method on it, but DateTime.new overrides it. This is the old habit before ruby 1.8. Although I'm uncertain why you need it, if you really need a class to represent arbitrary time but don't need precise historical time, you can use Time also, instead of DateTime. ---------------------------------------- Bug #6547: DateTime.new does not call #initialize https://bugs.ruby-lang.org/issues/6547#change-27019 Author: lmc (Luke Mcildoon) Status: Assigned Priority: Low Assignee: tadf (tadayoshi funaba) Category: ext Target version: ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux] Classes that extend DateTime don't appear to have their "initialize" instance method called from "new". To reproduce: irb(main):001:0> [RUBY_VERSION,RUBY_PLATFORM] => ["1.9.3", "i686-linux"] irb(main):002:0> require "date" => true irb(main):003:0> class DateTimeExtension < DateTime irb(main):004:1> def initialize(*args) irb(main):005:2> raise "DateTimeExtension#initialize called" irb(main):006:2> end irb(main):007:1> end => nil irb(main):008:0> DateTimeExtension.new => # # no exception raised I expected calling "DateTimeExtension.new" to raise the exception from inside "initialize". -- http://bugs.ruby-lang.org/