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

Handle dates like "2001" and "2001-10" better #3

Open
zostay opened this issue Oct 4, 2012 · 4 comments
Open

Handle dates like "2001" and "2001-10" better #3

zostay opened this issue Oct 4, 2012 · 4 comments

Comments

@zostay
Copy link
Contributor

zostay commented Oct 4, 2012

If you enter a partial date like the above, it will sort of work, but it does so by falling back to Date::Manip. When that happens, it assumes you mean only a single day.

Thus, "2001" becomes:

# Got:
[ "2001-01-01 00:00:00", "2001-01-01 23:59:59" ]

# Expected:
[ "2001-01-01 00:00:00", "2001-12-31 23:59:59" ]

and "2001-10" becomes:

# Got:
[ "2001-10-01 00:00:00", "2001-10-01 23:59:59" ]

# Expected:
[ "2001-10-01 00:00:00", "2001-10-31 23:59:59" ]

These dates ought to be handled more naturally.

@zostay
Copy link
Contributor Author

zostay commented Oct 11, 2012

Looks like Date::Manip has some tools that are helpful in solving this problem correctly. It appears to be only available under DM6, but that's good enough for me.

We can detect which fields were given and which were implied during the parsing of the date. We can then use that to determine what the range should be.

See:

@zostay
Copy link
Contributor Author

zostay commented Oct 12, 2012

Or maybe it's completely useless. It seems to return that all fields are complete even when I just give it a year. I'm investigating whether I'm just doing it wrong or if there's a bug in the version Date::Manip I'm using.

@mjaquilina
Copy link
Owner

My general inclination is to avoid relying on Date::Manip as much as possible, except as the final fallback method. Not sure if that's for legitimate reasons or just NIH.

@zostay
Copy link
Contributor Author

zostay commented Oct 16, 2012

Yes, but if we fall back to it, it would be nice to do the right thing. Based on my experience here, the "complete" method does not act like the documentation says. I'm probably going to abandon the effort.

Speaking of NIH, ever heard of DateTime::Format::Natural?

GSGSyncBot pushed a commit to GrantStreetGroup/Date-RangeParser-EN that referenced this issue May 13, 2024
Merge in GITHUB/date-rangeparser-en from SM-4835 to master

* commit '10fa1a12a43e17d3c3e36b6292139b9f89230268':
  Carve around Date::Manip bug regarding the complete fields provided
  SM-4835 Move last or past weekday logic to the top and deal with times as we always do
  SM-4835 Add deprecation warning when DM5 is being used
  SM-4835 Add pluralization to weekdays test
  SM-4835 Refrain from re-scoping incomplete arrayref
  SM-4835 Add support for last or past NUMBER weekdays ago with times
  SM-4835 Fix indentation in POD
  SM-4835 Add support for both 'inf' and 'infinity' DateTime objects
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