serhii.net

In the middle of the desert you can say anything you want

16 Oct 2023

python library for parsing human dates dateparser

dateparser – python parser for human readable dates — DateParser 1.1.2 documentation

Directly from its docu:

>>> import dateparser
>>> dateparser.parse('12/12/12')
datetime.datetime(2012, 12, 12, 0, 0)
>>> dateparser.parse('Fri, 12 Dec 2014 10:55:50')
datetime.datetime(2014, 12, 12, 10, 55, 50)
>>> dateparser.parse('Martes 21 de Octubre de 2014')  # Spanish (Tuesday 21 October 2014)
datetime.datetime(2014, 10, 21, 0, 0)
>>> dateparser.parse('Le 11 Décembre 2014 à 09:00')  # French (11 December 2014 at 09:00)
datetime.datetime(2014, 12, 11, 9, 0)
>>> dateparser.parse('13 января 2015 г. в 13:34')  # Russian (13 January 2015 at 13:34)
datetime.datetime(2015, 1, 13, 13, 34)
>>> dateparser.parse('1 เดือนตุลาคม 2005, 1:00 AM')  # Thai (1 October 2005, 1:00 AM)
datetime.datetime(2005, 10, 1, 1, 0)

but I installed it because it can also do:

dateparser.parse("yesterday")
>>> datetime.datetime(2023, 10, 15, 15, 15, 37, 652629)
Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus