araddon / dateparse

GoLang Parse many date strings without knowing format in advance.
MIT License
2.04k stars 166 forks source link

Parsing things like "yesterday" #12

Open LeonB opened 7 years ago

LeonB commented 7 years ago

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

araddon commented 7 years ago

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

golliher commented 7 years ago

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.

araddon commented 7 years ago

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.

golliher commented 7 years ago

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).

ArcticSnowman commented 6 years ago

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

PonyTang3 commented 6 years ago

I like this one http://php.net/manual/en/function.strtotime.php

phanirithvij commented 4 years ago

I found these implementations Ruby Python

araddon commented 3 years ago

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.

rendaw commented 3 years ago

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