Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102891
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Gary Herron <gherron@digipen.edu> |
| Newsgroups | comp.lang.python |
| Subject | Re: problem with dateutil |
| Date | Sat, 13 Feb 2016 12:45:39 -0800 |
| Lines | 47 |
| Message-ID | <mailman.96.1455396346.22075.python-list@python.org> (permalink) |
| References | <di995iFr285U1@mid.individual.net> <mailman.94.1455387608.22075.python-list@python.org> <di9ht8FtcmgU1@mid.individual.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de VSw/QNrjioevCowN0rYHAA1/ZmBFPi+opPvnSBrD2+WQ== |
| Return-Path | <gherron@digipen.edu> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.033 |
| X-Spam-Evidence | '*H*': 0.93; '*S*': 0.00; 'modify': 0.04; 'tom': 0.07; '22,': 0.09; 'format?': 0.09; 'skip:p 40': 0.15; '"every': 0.16; '09:58': 0.16; 'colons': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'result:': 0.16; 'try/except': 0.16; 'wrote:': 0.16; 'odd': 0.18; 'thanks.': 0.18; '>>>': 0.20; 'saying': 0.22; 'subject:problem': 0.22; 'am,': 0.23; 'header:In- Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'separate': 0.27; 'format,': 0.27; 'specify': 0.27; 'looks': 0.29; '13,': 0.29; 'about.': 0.29; 'convert': 0.29; 'code': 0.30; "can't": 0.32; 'getting': 0.33; 'handle': 0.34; 'skip:d 20': 0.34; 'could': 0.35; 'formats': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'wrong': 0.38; 'means': 0.39; 'whatever': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'care': 0.60; 'your': 0.60; 'charset:windows-1252': 0.62; 'course': 0.62; 'dr.': 0.69; 'received:204': 0.75; 'institute': 0.77; '(425)': 0.84; '895-4418': 0.84; 'afaics': 0.84; 'digipen': 0.84; 'herron': 0.84; 'now...': 0.84 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
| In-Reply-To | <di9ht8FtcmgU1@mid.individual.net> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:102891 |
Show key headers only | View raw
On 02/13/2016 12:27 PM, Tom P wrote: > On 02/13/2016 07:13 PM, Gary Herron wrote: >> On 02/13/2016 09:58 AM, 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? >>> >> >> Yes, there is a way to specify your own format. Search the datetime >> documentation for >> datetime.strptime(date_string, format) >> >> Gary Herron >> > > Thanks. I started out with datetime.strptime but AFAICS that means I > have to go through try/except for every conceivable format. Are you > saying that I can't use dateutil.parser? Well now... If by "every conceivable format" you are including formats that the author of dateutil.parser did not conceive of, then of course you cannot use dateutil.parser. But you have the code for dateutil.parser -- perhaps you could modify it to accept whatever odd formats you care about. Gary Herron -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
problem with dateutil Tom P <werotizy@freent.dd> - 2016-02-13 18:58 +0100
Re: problem with dateutil Gary Herron <gherron@digipen.edu> - 2016-02-13 10:13 -0800
Re: problem with dateutil Tom P <werotizy@freent.dd> - 2016-02-13 21:27 +0100
Re: problem with dateutil Gary Herron <gherron@digipen.edu> - 2016-02-13 12:45 -0800
Re: problem with dateutil Tom P <werotizy@freent.dd> - 2016-02-14 13:26 +0100
Re: problem with dateutil Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-02-13 21:01 +0000
Re: problem with dateutil Tom P <werotizy@freent.dd> - 2016-02-14 13:27 +0100
csiph-web