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

[Gem bug only] Parser handles missing years differently with numbers vs month names #397

Open
agrberg opened this issue Dec 31, 2019 · 2 comments

Comments

@agrberg
Copy link

agrberg commented Dec 31, 2019

Chronic will advance the year properly for a date that is past for the current year if given in mm/dd format but it will not for month_name dd.

# Let's make it 11/11/2020
now = Chronic.construct(2020, 11, 11) # => 2020-11-11 00:00:00 -0500
# The first of November is in the past for 2020 so both "Nov 1" and "11/1" should be 11/1/21
Chronic.parse("11/1", now: now)       # => 2021-11-01 12:00:00 -0400
# but it isn't with the month's name
Chronic.parse("Nov 1", now: now)      # => 2020-11-01 11:00:00 -0500

# It uses the current year as expected for the current date or a date in the future
Chronic.parse("11/11", now: now)  # => 2020-11-11 12:00:00 -0500
Chronic.parse("Nov 11", now: now) # => 2020-11-11 12:00:00 -0500
Chronic.parse("11/12", now: now)  # => 2020-11-12 12:00:00 -0500
Chronic.parse("Nov 12", now: now) # => 2020-11-12 12:00:00 -0500

A little bit of digging suggests the reason is that the day is not taken into account in RepeaterMonthName#next. Is this the correct behavior or am I'm missing something?

@agrberg
Copy link
Author

agrberg commented Dec 31, 2019

This seems to be a problem on the latest release of the gem v 0.10.2. This is not the case on Master as it appears this line fixed it.

@agrberg agrberg changed the title Parser handles missing years differently with numbers vs month names [Gem bug only] Parser handles missing years differently with numbers vs month names Dec 31, 2019
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

No branches or pull requests

2 participants
@agrberg and others