Project

General

Profile

Actions

Backport #8238

closed

Prepending any module to DateTime causes infiinite loop when using zone-related methods

Added by mjtko (Mark Titorenko) over 11 years ago. Updated about 11 years ago.


Description

Prepending a Module to DateTime and then inspecting or trying to use any of the methods associated with the timezone causes what appears to be an inifinite loop.

The following code demonstrates the issue:

require 'date'
DateTime.instance_eval { prepend Module.new }
DateTime.now.offset

A cursory inspection shows that similar results (or lack of!) are yielded from #zone, #hour, #minute etc. though #year, #month and #day appear unaffected:

2.0.0p0 :001 > require 'date'
=> true
2.0.0p0 :002 > DateTime.instance_eval { prepend Module.new }
=> DateTime
2.0.0p0 :003 > d = DateTime.now; nil
=> nil
2.0.0p0 :004 > d.year
=> 2013
2.0.0p0 :005 > d.month
=> 4
2.0.0p0 :006 > d.day
=> 8
2.0.0p0 :007 > d.minute
^C

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0