Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/evyatarmeged/date-parser

Parsing date strings into a datetime object
https://github.com/evyatarmeged/date-parser

dateparser parsing python

Last synced: about 1 month ago
JSON representation

Parsing date strings into a datetime object

Awesome Lists containing this project

README

        

# Date-parser
Parse different date strings into datetime objects.

#### Installation
`pip3 install date-parser`

#### Usage

```
from date_parser.parser import DateParser
dp = DateParser()
```
Natural language
```
dp.parse_date('September 24th 1929')
>> datetime.datetime(1929, 9, 24, 0, 0)
```
Natural language - shortened month
```
dp.parse_date('Jan 14th 1999')
>> datetime.datetime(1999, 1, 14, 0, 0, 0)
```
Hyphens
```
dp.parse_date('01-01-2017')
>> datetime.datetime(2017, 1, 1, 0, 0)
```
Dots

```
dp.parse_date('19.11.1984')
>> datetime.datetime(1984, 11, 19, 0, 0, 0)
```
Forward slash
```
dp.parse_date('30/09/1542)
>> datetime.datetime(1542, 9, 30, 0, 0, 0)

```
Another natural language example
```
print(dp.parse_date('On 2012, I believe it was May 19th, Chelsea won the Champions League.'))
>> 2012-05-19 00:00:00

```