Hello. I found this different behaviour for DateTime#to_f and Time#to_f. DateTime#to_f strips decimal part but Time#to_f doesn''t. DateTime#to_f method is implemented in ActiveSupport and Time#to_f is native conversion method. failing test: https://gist.github.com/simi/7343708 I found this in mongoid pending test ( https://github.com/mongoid/mongoid/blob/master/spec/mongoid/extensions/date_time_spec.rb#L17 ). It was marked as pending in change from 3.2 to 4.0 rails. So it'' regression maybe. But I tried 3.2, 3.1, 3.0 and 2.3 in console quickly and it behaved same as now. So I''m not sure about this. Anyway ping me if you think any patch is needed for this and I''ll do my best to provide it. Regards, Josef Šimánek https://github.com/simi -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Rafael Mendonça França
2013-Nov-06 21:02 UTC
Re: DateTime#to_f and Time#to_f inconsistency
The only related commit that I could find was https://github.com/rails/rails/commit/822c858a1a5cad49274404dbc10b7f8107b06cc3 . Andrew, could you take a look? Rafael Mendonça França http://twitter.com/rafaelfranca https://github.com/rafaelfranca On Wed, Nov 6, 2013 at 6:56 PM, Josef Šimánek <josef.simanek@gmail.com>wrote:> Hello. > > I found this different behaviour for DateTime#to_f and Time#to_f. > DateTime#to_f strips decimal part but Time#to_f doesn''t. > > DateTime#to_f method is implemented in ActiveSupport and Time#to_f is > native conversion method. > > failing test: > https://gist.github.com/simi/7343708 > > I found this in mongoid pending test ( > https://github.com/mongoid/mongoid/blob/master/spec/mongoid/extensions/date_time_spec.rb#L17 > ). > It was marked as pending in change from 3.2 to 4.0 rails. So it'' > regression maybe. But I tried 3.2, 3.1, 3.0 and 2.3 in console quickly and > it behaved same as now. So I''m not sure about this. > > Anyway ping me if you think any patch is needed for this and I''ll do my > best to provide it. > > Regards, > Josef Šimánek > https://github.com/simi > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Sorry guys, Mongoid is using own kind of magic for this ( https://github.com/mongoid/mongoid/blob/master/lib/mongoid/extensions/date_time.rb#L14) and it looks it doesn''t work with rails 4. So it is not regression in DateTime anyway. But the question remains. Is this expected behaviour to strip decimal part for to_float conversion of DateTime? 2013/11/6 Rafael Mendonça França <rafaelmfranca@gmail.com>> The only related commit that I could find was > https://github.com/rails/rails/commit/822c858a1a5cad49274404dbc10b7f8107b06cc3 > . > > Andrew, could you take a look? > > Rafael Mendonça França > http://twitter.com/rafaelfranca > https://github.com/rafaelfranca > > > On Wed, Nov 6, 2013 at 6:56 PM, Josef Šimánek <josef.simanek@gmail.com>wrote: > >> Hello. >> >> I found this different behaviour for DateTime#to_f and Time#to_f. >> DateTime#to_f strips decimal part but Time#to_f doesn''t. >> >> DateTime#to_f method is implemented in ActiveSupport and Time#to_f is >> native conversion method. >> >> failing test: >> https://gist.github.com/simi/7343708 >> >> I found this in mongoid pending test ( >> https://github.com/mongoid/mongoid/blob/master/spec/mongoid/extensions/date_time_spec.rb#L17 >> ). >> It was marked as pending in change from 3.2 to 4.0 rails. So it'' >> regression maybe. But I tried 3.2, 3.1, 3.0 and 2.3 in console quickly and >> it behaved same as now. So I''m not sure about this. >> >> Anyway ping me if you think any patch is needed for this and I''ll do my >> best to provide it. >> >> Regards, >> Josef Šimánek >> https://github.com/simi >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-core+unsubscribe@googlegroups.com. >> >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ruby on Rails: Core" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/rubyonrails-core/liwxWW3veZE/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.