It was 6 years ago when Zyte (formerly Scrapinghub) released Dateparser, an open source library that parses human-readable dates, and in October 2020 we released version 1.0.0, a very important milestone. In this article, I’d like to introduce this library and share some insights into why it’s so popular.
Dateparser was developed to make date extraction from HTML pages easier. Initially, it was used only by web scraping developers, but later it was quickly adopted by the wider community as well. It has been used for multiple applications like command-line tools, chatbots, etc.
Read more about Dateparser on Github.
More than 5.7K projects in GitHub list Dateparser as a dependency. Some examples are:
According to PyPI Download Stats, last month Dateparser was downloaded 1.65M times. That’s 2200+ downloads every hour!
Dateparser also has 1.8K stars on Github and this number keeps growing.
When you are building software, dealing with date strings and parsing them can become very difficult and tedious: it is very hard to foresee all cases and build something that works efficiently. However, you should always look for ways to use existing solutions and avoid reinventing the wheel, and this is where Dateparser comes in handy: Dateparser can convert dates in all sorts of formats and locales to date time objects.
It would take a lot of time to create something so powerful from scratch, but instead, all you need to do is import Dateparser and use it.
Using Dateparser is as simple as importing it and calling the `parse()` method:
>>> import dateparser >>> dateparser.parse('20/11/2021') datetime.datetime(2021, 11, 20, 0, 0)
Of course, you can do a lot more than this. But you can start using it without any heavy setup and without reading a lot of documentation.
Even if the interface is really simple, you can handle a lot of nuances by using the settings. You can pick a reference date, select the preferred date order, adjust the timezone configuration, decide how to handle incomplete dates, etc.
Is there something you want to achieve? Take a look at the settings and you will probably find what you were looking for.
Good code comes with automated tests that provide good code coverage. Dateparser has a code coverage of >98%, with examples in many languages.
Building and maintaining open source projects is in our DNA, and we have been really proud to see this -little- project growing during the years!
If you want to learn more about Dateparser, a date parsing library, and how to use it in your project check out these links: