Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Tom P Newsgroups: comp.lang.python Subject: Re: problem with dateutil Date: Sun, 14 Feb 2016 13:27:51 +0100 Lines: 36 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net p5HuxJ56YR7qxtrb6+2xQAgq2z6M0wggYBzslHtTc3dkMMcug= Cancel-Lock: sha1:ByZcS0XmiVuTgjF26JxblVy0iYM= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: Xref: csiph.com comp.lang.python:102913 On 02/13/2016 10:01 PM, Mark Lawrence wrote: > On 13/02/2016 17:58, Tom P wrote: >> I am writing a program that has to deal with various date/time formats >> and convert these into timestamps. It looks as if dateutil.parser.parse >> should be able to handle about any format, but what I get is: >> >> datetimestr = '2012-10-22 11:22:33' >> print(dateutil.parser.parse(datetimestr)) >> result: datetime.datetime(2012, 10, 22, 11, 22, 33) >> >> However: >> datetimestr = '2012:10:22 11:22:33' >> print(dateutil.parser.parse(datetimestr)) >> result: datetime.datetime(2016, 2, 13, 11, 22, 33) >> >> In other words, it's getting the date wrong when colons are used to >> separate YYYY:MM:DD. Is there a way to include this as a valid format? >> > > From > http://labix.org/python-dateutil#head-a23e8ae0a661d77b89dfb3476f85b26f0b30349c > > > > parserinfo > This parameter allows one to change how the string is parsed, by > using a different parserinfo class instance. Using it you may, for > example, intenationalize the parser strings, or make it ignore > additional words. > > > HTH. > Thanks, let me look at that.