GithubHelp home page GithubHelp logo

Comments (10)

adzap avatar adzap commented on July 17, 2024

I suppose my thought was that AM and an hour > 12 is contradictory. Though both are invalid meridian times.

There is no option to change this behaviour, it requires a code change. For the v3 it requires a change to the Timeliness gem, which is not great problem.

Which version of the plugin are you using?

from validates_timeliness.

vhalis avatar vhalis commented on July 17, 2024

I'm using 3.0.5 of validates_timeliness and 0.3.3 of timeliness.

PM and hour > 12 should be contradictory too, no?

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

Yes, perhaps.

I went to add a failing spec in Timeliness to test the behaviour and it should currently return a nil value. This is because it will try to make a time instance with an hour of 13 + 12 (for PM) which will throw an error.

Can you give me a failing spec for this?

from validates_timeliness.

vhalis avatar vhalis commented on July 17, 2024

I can't figure it out. I've tried to make a failing spec in both timeliness and validates_timeliness, and neither one will make a time from "13:00pm." I made this test in validator_spec:

     it "is a test" do
     person.birth_datetime = "13:00pm"
     person.invalid?
     person.birth_datetime.should eql(52) 
     person.errors[:birth_datetime].should_not be_empty
 end

and inserted it at line 134. person.invalid? does not fail (same results with person.valid?), but person.birth_datetime.should eql(52) tells me that birth_datetime is nil. However, on my own testing with a model that has validates_datetime for :departure, and with b.departure = "13:00pm", using b.departure.to_s gives me 2011-02-16 13:00:00 UTC.

Any ideas?

from validates_timeliness.

vhalis avatar vhalis commented on July 17, 2024

I made the smallest rails app I could to try and isolate the problem, and with only one model that has only a datetime and no other gems added to the Gemfile except validates_timeliness, I can assign "13:00pm" to my model and it turns into "13:00:00."

I uploaded it here: https://github.com/vhalis/validates_datetime-Meridian-PM-times

I'm really not sure what's going on, sorry. :(

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

I think the problem is that you don't have the plugin parser turned on. This is done in the config initializer output by the generator. You are possibly seeing the regular time parsing of this value.

from validates_timeliness.

vhalis avatar vhalis commented on July 17, 2024

I ran the generator for the install and uncommented the config.use_plugin_parser and set it to true. However, the test still has the same result. Also pushed new version to github.

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

I've tracked it down to the railtie not loading the ActiveRecord extension by default, meaning the parser was not being used. If you uncomment the config.extend_orms [ :active_record ] line in the initializer it works as expected.

Will look into a fix.

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

Closing this and opening a new issue with description pointing here.

from validates_timeliness.

vhalis avatar vhalis commented on July 17, 2024

Thanks a bunch, things work as expected with that. Thanks for your time!

from validates_timeliness.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.