akoumjian / datefinder

Find dates inside text using Python and get back datetime objects
http://datefinder.readthedocs.org/en/latest/
MIT License
635 stars 167 forks source link

How to specify single format of date. #117

Closed Bipulkumarsingh closed 3 years ago

Bipulkumarsingh commented 4 years ago

I am facing problem with date format Input_1 -> Input :- 10/12/2018 Output:- 12-October-2018 Input_2 -> Input:- 25/12/2018 Output:- 25-December-2018

I want to specify single date format %d-%B-%y for all dates, How can i achieve this in datefinder.

HarishOsthe commented 4 years ago

Hey @Bipulkumarsingh sorry for the late reply. On 2 Aug 2020 Add options for ambiguous integer dates , where @akoumjian have added a new argument first. weather to interpret the first value in an ambiguous 3-integer date (01/02/03) as the month, day, or year. Values can be month, day, year. The default is month.

this version is not yet updated in Pypi

To install this manually. (I'm using Ubuntu 20.04 LTS)

  1. Clone this Repo git clone https://github.com/akoumjian/datefinder.git

  2. Change the directory cd datefinder/

  3. To install for user python3 setup.py install --user

that's it.

Test the install

import datefinder
dates = datefinder.find_dates(' FROM 18:08 ON 10/12/2018 TO MIDNIGHT OF 25/12/2018', first="day")
for d in dates:
    print(d)

Output

2018-12-10 18:08:00
2018-12-25 00:00:00