Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evyatarmeged/date-parser
Parsing date strings into a datetime object
https://github.com/evyatarmeged/date-parser
dateparser parsing python
Last synced: 2 months ago
JSON representation
Parsing date strings into a datetime object
- Host: GitHub
- URL: https://github.com/evyatarmeged/date-parser
- Owner: evyatarmeged
- License: mit
- Created: 2017-07-17T15:22:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-09T11:18:35.000Z (about 7 years ago)
- Last Synced: 2024-10-11T18:18:43.541Z (3 months ago)
- Topics: dateparser, parsing, python
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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```