#325 ✓resolved
MartOn

Bug in Datetime

Reported by MartOn | November 11th, 2008 @ 10:44 PM

Hello, It seems there is a bug in datetime in hobo, because I can not replicate this in a regular rails app.
If I have a Club model with a :founded of type :datetime and from script console do this:

>> a = Club.new
=> #<Club id: nil, founded: nil, created_at: nil, updated_at: nil>
>> a.founded = "01.03.1882"
=> "01.03.1882"
>> a.save
=> true

everything seems to work, but if I do this:

?> a = Club.new(:founded => "01.01.1892")
ArgumentError: time out of range
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/time.rb:184:in `local'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/time.rb:184:in `make_time'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/time.rb:243:in `parse'
    from /Library/Ruby/Gems/1.8/gems/hobo-0.8.3/lib/hobo/model.rb:587:in `parse_datetime'
    from /Library/Ruby/Gems/1.8/gems/hobo-0.8.3/lib/hobo/model.rb:620:in `convert_type_for_mass_assignment'
    from /Library/Ruby/Gems/1.8/gems/hobo-0.8.3/lib/hobo/model.rb:496:in `attributes='
    from /Library/Ruby/Gems/1.8/gems/hobosupport-0.8.3/lib/hobosupport/hash.rb:12:in `map_hash'
    from /Library/Ruby/Gems/1.8/gems/hobosupport-0.8.3/lib/hobosupport/hash.rb:12:in `each'
    from /Library/Ruby/Gems/1.8/gems/hobosupport-0.8.3/lib/hobosupport/hash.rb:12:in `map_hash'
    from /Library/Ruby/Gems/1.8/gems/hobo-0.8.3/lib/hobo/model.rb:496:in `attributes='
    from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:2141:in `initialize'
    from (irb):6:in `new'
    from (irb):6

As you can see it crashes.
This is not the case for a regular rails app.

Here is how I created the app:

hobo datetimer
script/generate hobo_model_resource Club founded:datetime
script/generate hobo_migration
script/console

/MartOn

Comments and changes to this ticket

  • Tom Locke

    Tom Locke December 1st, 2008 @ 03:53 PM

    • State changed from “new” to “resolved”

    Fixed. This was introduced with Hobo's support for date parsing using Chronic. I've since realised that it was a bad idea to switch this on for every date/time field, and removed that feature.

    Will go back in as a rich type later

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Tags

Pages