TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Dateparser: Python parser for human readable dates

89 pointsby juanriazaover 10 years ago

12 comments

Negative1over 10 years ago
In the same vein check out Arrow for a big improvement over Pythons standard time&#x2F;date libraries. As a bonus it also generates human readable dates (though I don&#x27;t think it parses them like this lib): <a href="http://crsmithdev.com/arrow/" rel="nofollow">http:&#x2F;&#x2F;crsmithdev.com&#x2F;arrow&#x2F;</a>
评论 #8654671 未加载
评论 #8655841 未加载
rafdover 10 years ago
Huh! Just last week I did a survey of NLP Date Parsing libraries. If you&#x27;re looking got something similar in other languages, see:<p><a href="https://docs.google.com/spreadsheets/d/1dKt0R247B8Mx5sFXd7htSOQB-B5kMODM2ydmjp9cr80/edit?usp=sharing" rel="nofollow">https:&#x2F;&#x2F;docs.google.com&#x2F;spreadsheets&#x2F;d&#x2F;1dKt0R247B8Mx5sFXd7ht...</a>
jmsdnnsover 10 years ago
Python also has dateutil, which can do similar things and has been around a long time: <a href="https://pypi.python.org/pypi/python-dateutil" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;python-dateutil</a>
评论 #8654301 未加载
评论 #8654999 未加载
superchinkover 10 years ago
So quick question to anyone who&#x27;s used this lib. The README cites an example: it can give you the date for text like: &#x27;1 min ago&#x27;, &#x27;2 weeks ago&#x27;, &#x27;3 months, 1 weeks and 1 day ago&#x27;, etc<p>Does it handle proper grammar for singular values (i.e., 1 week vs. 1 weeks)?
评论 #8655026 未加载
评论 #8654435 未加载
foxhopover 10 years ago
Sort of related, I&#x27;m the author of ago.py (<a href="https://pypi.python.org/pypi/ago/0.0.6" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;ago&#x2F;0.0.6</a>) which generates human readable timedeltas that this parser reverses.
rmrfrmrfover 10 years ago
I&#x27;m ashamed to say that, in the few Python projects I&#x27;ve done, I have resorted to delegating date parsing out to PHP in the past given its amazing date parser. Aside from how silly that sounds, it&#x27;s actually a pretty fast solution. I&#x27;ll give this a look and see how it compares. I&#x27;ve found that a lot of Python libraries seem to add an obscene amount of bloat for the functionality I&#x27;m looking for.
评论 #8655636 未加载
评论 #8656285 未加载
callmeedover 10 years ago
FYI the ruby equivalent is chronic: <a href="https://github.com/mojombo/chronic" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mojombo&#x2F;chronic</a>
brendanoover 10 years ago
Also see Heideltime: <a href="https://code.google.com/p/heideltime/" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;heideltime&#x2F;</a>
mashematicianover 10 years ago
Similar project: <a href="https://github.com/bear/parsedatetime" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bear&#x2F;parsedatetime</a>
ar7hurover 10 years ago
FYI in Clojure (with a live demo): <a href="http://duckling-lib.org" rel="nofollow">http:&#x2F;&#x2F;duckling-lib.org</a>
评论 #8655654 未加载
boyterover 10 years ago
Interesting. However it doesn&#x27;t solve what I would argue is the harder problem of how to identify a time in the document.<p>For example as I write this HN url says that it is 8 hours old. Without knowing the exact format how can I extract these sort of dates out of random text&#x2F;html documents?
评论 #8656145 未加载
评论 #8656108 未加载
thraxilover 10 years ago
related, for parsing durations: <a href="https://github.com/thraxil/simpleduration/" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;thraxil&#x2F;simpleduration&#x2F;</a>
评论 #8655434 未加载