matthewmueller / date

Date() for humans
http://matthewmueller.github.io/date/
1.48k stars 88 forks source link

Add no extra day with months in the past #69

Closed HipsterBrown closed 8 years ago

HipsterBrown commented 8 years ago

Context: When trying to parse a future date with a month, like today is "20th of November" and the future date being parsed is "9th of December". The returned date from date.js would be off by one, i.e. a Date object for the 8th of December.

Solution: I added a test for '9th of December 4:00am' and got the same bug I was running into in my own app. To fix this issue, I modified parser.nextTime to look for a match with the rMonths regex and not add a day to the date.

I hope this makes sense. I appreciate all the work that went into making this awesome library. Thanks for considering this PR.

matthewmueller commented 8 years ago

awesome thanks @HipsterBrown for the well-explained description, implementation and tests!

HipsterBrown commented 8 years ago

Just saw this got merged. :clap:

I'd like to add support for a different month/date format, i.e. "November 29th", next. Just a heads up.