I have isolated what appears to be a bug in the Rails extensions to
DateTime, but I don't know where to report it.

I have a standalone file to demonstrate the bug, but the punch line is
that this code:

TestRecord.create!(:f_datetime => (expected = DateTime.jd(2000000)))
found = TestRecord.first.f_datetime

puts("expected == found => #{expected == found}")
puts("expected = #{expected.to_formatted_s(:rfc822)}")
puts("found = #{found.to_formatted_s(:rfc822)}")

generates this response:

expected == found => true
expected = Wed, 14 Sep 0763 00:00:00 +0000
found = Sat, 14 Sep 0763 00:00:00 +0000

So. The dates are equal, but was that day a Wednesday or a Saturday?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Jun 21, 2012 at 4:52 pm

    On 21 June 2012 17:36, Fearless Fool wrote:
    I have isolated what appears to be a bug in the Rails extensions to
    DateTime, but I don't know where to report it.

    I have a standalone file to demonstrate the bug, but the punch line is
    that this code:

    TestRecord.create!(:f_datetime => (expected = DateTime.jd(2000000)))
    found = TestRecord.first.f_datetime

    puts("expected == found => #{expected == found}")
    puts("expected = #{expected.to_formatted_s(:rfc822)}")
    puts("found =    #{found.to_formatted_s(:rfc822)}")

    generates this response:

    expected == found => true
    expected = Wed, 14 Sep 0763 00:00:00 +0000
    found =      Sat, 14 Sep 0763 00:00:00 +0000

    So.  The dates are equal, but was that day a Wednesday or a Saturday?
    Can you post the contents of schema.rb section for the table.
    Also it would be interesting to put in some inspect debug for expected
    and found.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Fearless Fool at Jun 21, 2012 at 5:05 pm

    Can you post the contents of schema.rb section for the table.
    Also it would be interesting to put in some inspect debug for expected
    and found.
    Colin:

    Done. See https://gist.github.com/2967023 for code and results.

    As for "inspect debug for expected and found", I assume you mean like
    this:

    puts("expected = #{expected.to_formatted_s(:rfc822)}
    (#{expected.inspect})")
    puts("found = #{found.to_formatted_s(:rfc822)}
    (#{found.inspect})")

    =>

    expected = Wed, 14 Sep 0763 00:00:00 +0000 (Wed, 14 Sep 0763 00:00:00
    +0000)
    found = Sat, 14 Sep 0763 00:00:00 +0000 (Sat, 14 Sep 0763 00:00:00
    UTC +00:00)

    HTH.

    - ff

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jun 22, 2012 at 7:24 am

    On 21 June 2012 18:05, Fearless Fool wrote:
    Can you post the contents of schema.rb section for the table.
    Also it would be interesting to put in some inspect debug for expected
    and found.
    Colin:

    Done.  See https://gist.github.com/2967023 for code and results.

    As for "inspect debug for expected and found", I assume you mean like
    this:

    puts("expected = #{expected.to_formatted_s(:rfc822)}
    (#{expected.inspect})")
    puts("found =    #{found.to_formatted_s(:rfc822)}
    (#{found.inspect})")
    What is the class of found?

    Colin
    =>

    expected = Wed, 14 Sep 0763 00:00:00 +0000 (Wed, 14 Sep 0763 00:00:00
    +0000)
    found =    Sat, 14 Sep 0763 00:00:00 +0000 (Sat, 14 Sep 0763 00:00:00
    UTC +00:00)

    HTH.

    - ff

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jun 23, 2012 at 8:45 pm

    On 22 June 2012 08:23, Colin Law wrote:
    On 21 June 2012 18:05, Fearless Fool wrote:
    Can you post the contents of schema.rb section for the table.
    Also it would be interesting to put in some inspect debug for expected
    and found.
    Colin:

    Done.  See https://gist.github.com/2967023 for code and results.

    As for "inspect debug for expected and found", I assume you mean like
    this:

    puts("expected = #{expected.to_formatted_s(:rfc822)}
    (#{expected.inspect})")
    puts("found =    #{found.to_formatted_s(:rfc822)}
    (#{found.inspect})")
    What is the class of found?
    Also I don't think you have told us which versions of ruby and rails
    you are using.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Fearless Fool at Jun 25, 2012 at 8:13 pm

    Colin Law wrote in post #1065800:
    What is the class of found?
    I updated the above mentioned gist. 'expected' is a DateTme, 'found' is
    ActiveSupport::TimeWithZone.
    Also I don't think you have told us which versions of ruby and rails
    you are using.
    Apologies, this was buried at the end of the OP:
    PS: I'm using postgresql with Ruby 1.93 and Rails 3.2.1
    But this is all now moot: I posted this as a Rails issue:

    https://github.com/rails/rails/issues/6814

    where @pixeltrix patiently educated me on the anomalies of ancient
    calendar systems. The best line was "[calendar reforms] can lead to
    oddities like William Shakespeare and Miguel de Cervantes dying on the
    same date but 10 days apart." He also suggests using #gregorian to
    adjust the datetime before converting to time, e.g:
    DateTime.jd(2000000).gregorian
    => Wed, 18 Sep 0763 00:00:00 +0000

    So: not a bug. Just a reality of calendar reforms.

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Fearless Fool at Jun 21, 2012 at 6:13 pm
    I've created:

    https://github.com/rails/rails/issues/6814

    ... which seems like the correct place to report this. I'm sure I'll
    hear from the rails admin team soon enough if that's not the right
    place.

    - ff

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJun 21, '12 at 4:36p
activeJun 25, '12 at 8:13p
posts7
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Fearless Fool: 4 posts Colin Law: 3 posts

People

Translate

site design / logo © 2022 Grokbase