dateparse icon indicating copy to clipboard operation
dateparse copied to clipboard

Parsing things like "yesterday"

Open LeonB opened this issue 7 years ago • 9 comments

Would parsing thing like "yesterday" and "previous month" be something that's in the scope of this project?

LeonB avatar Jun 30 '17 13:06 LeonB

Interesting question, i like the general idea but want to investigate a bit. Do you have any domain body of knowledge (aka other projects, python, node?) that do this that you like? Would you see the words as a controlled vocabulary of specific words?

This question also makes me think about our other project here that we use inside our code-base a lot related to this. https://github.com/lytics/datemath

araddon avatar Jun 30 '17 17:06 araddon

This project handles natural language parsing.. https://github.com/olebedev/when It doesn't handle everything I need though so I'm currently parsing it and if that fails parsing with dateparse as a second attempt. Neither handle exactly what I want because neither can parse "10/1" as October 1st of the current year which is what I want for my little project.

golliher avatar Sep 30 '17 15:09 golliher

Yes, i should add that library as a link from readme as an alternate. I wonder if i should add "10/1" as a format in here. My concern would be ambiguity on mm/dd vs mm/yy.

araddon avatar Sep 30 '17 16:09 araddon

I can see how ambiguity would be a problem. Perhaps the same solution to issue#1 would work here? i.e. a different function name for parsing USA standard (10/1) vs (1/10 -- assuming someone somewhere uses that as their standard).

golliher avatar Sep 30 '17 18:09 golliher

Perl has http://search.cpan.org/~aquilina/Date-RangeParser-EN-0.06/lib/Date/RangeParser/EN.pm

ArcticSnowman avatar Feb 05 '18 20:02 ArcticSnowman

I found these implementations Ruby Python

phanirithvij avatar Oct 23 '20 18:10 phanirithvij

I know there is interest in this. However, as i think through the ramifications i can't help but lean towards saying no, not for this library. The scope of human-authored vs machine-authored date formats is just too large of a difference, especially given language differences. So, i think any human-authored dates will be out of scope for this library.

araddon avatar Oct 28 '20 17:10 araddon

For reference, systemd time parsing is fairly comfortable (ex logs "from 3 days ago"): https://www.systutorials.com/docs/linux/man/7-systemd/ Here's another library that does it fairly well https://github.com/scrapinghub/dateparser

rendaw avatar Feb 06 '21 03:02 rendaw