Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parsing impossible dates #56

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

DomeCaiazza
Copy link
Contributor

Ciao, facendo delle prove mi sono accorto che nel caso in cui venga indicata una data impossibile (ad esempio il 30 febbraio) la decodifica andava in errore:
/Users/domenico/.rvm/gems/ruby-3.2.3@faker/gems/itax_code-2.0.4/lib/itax_code/parser.rb:86:in parse': invalid date (Date::Error)

    @birthdate ||= Date.parse("#{year}-#{month}-#{day}").to_s
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
from /Users/domenico/.rvm/gems/ruby-3.2.3@faker/gems/itax_code-2.0.4/lib/itax_code/parser.rb:86:in `birthdate'
from /Users/domenico/.rvm/gems/ruby-3.2.3@faker/gems/itax_code-2.0.4/lib/itax_code/parser.rb:34:in `decode'
from /Users/domenico/.rvm/gems/ruby-3.2.3@faker/gems/itax_code-2.0.4/lib/itax_code.rb:32:in `decode'
from /Users/domenico/.rvm/gems/ruby-3.2.3@faker/gems/itax_code-2.0.4/lib/itax_code.rb:41:in `valid?'
from aa.rb:7:in `block in <main>'
from aa.rb:4:in `times'
from aa.rb:4:in `<main>'`

ho corretto il bug e aggiunto un test

matteoredz
matteoredz previously approved these changes Oct 22, 2024
Copy link
Owner

@matteoredz matteoredz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ciao @DomeCaiazza, grazie mille, ha perfettamente senso 😄

The `Date::Error` exception class was added with Ruby 2.7 but this gem still supports a couple of versions below that.
@matteoredz matteoredz self-requested a review October 22, 2024 10:19
@matteoredz matteoredz merged commit 4f5cc91 into matteoredz:main Oct 22, 2024
9 of 10 checks passed
This was referenced Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants