GithubHelp home page GithubHelp logo

Don't work with Date about date_validator HOT 3 CLOSED

codegram avatar codegram commented on July 17, 2024
Don't work with Date

from date_validator.

Comments (3)

txus avatar txus commented on July 17, 2024

Sorry, I couldn't apply your pull request because it breaks a spec (the one checking the :after_or_equal_to clause).
Turns out that somehow comparing two equal datetimes or times with >= (but not with <=) returns false. I've been researching but the best solution I found a couple days ago was to convert them to integer before comparing them; now I've fixed that Date thing converting all TimeWithZones and Dates to datetime before the to_i, so there should be no problem now.
Let me know if you find out about that datetime comparison strange issue, maybe it's my ruby version or I don't know! And thank you for contributing ;)

from date_validator.

naumov avatar naumov commented on July 17, 2024

Thanks for so quick fix! :)

But there is small issue in your fix, too. It is when you do value = value.to_datetime and then pass record.errors.add(... :value => value ...). The original value is a Date, but the one is passed to i18n error message is an Datetime(becouse you convert the value directly). This couse a small issue with formatting in error messages.

I think it is better to introduce a new variable for comparison, but pass the original one to i18n error.

from date_validator.

txus avatar txus commented on July 17, 2024

Yep! fixed. However I'm thinking this actually means that the i18n part is not covered by tests, so I think maybe tomorrow I'm giving it a try and get it covered to avoid future bugs!

from date_validator.

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.