From bartbkr at gmail.com Tue Jan 24 16:45:25 2017 From: bartbkr at gmail.com (Bart Baker) Date: Tue, 24 Jan 2017 16:45:25 -0500 Subject: [Dateutil] Retrieving format string from parsed string Message-ID: Hello, I was wondering if it is possible to retrieve the inferred format string from a parsed date str. For example, if I parse a str as follows: import dateutil mystr = '1990/04/22' parsed = dateutil.parser.parse(mystr) Is there any way to retrieve 'YYYY/MM/DD'? I'm assuming the returned datetime object doesn't retain the information. I would appreciate any help that you could offer. Thank you, Bart From paul at ganssle.io Tue Jan 24 18:21:23 2017 From: paul at ganssle.io (Paul G) Date: Tue, 24 Jan 2017 18:21:23 -0500 Subject: [Dateutil] Retrieving format string from parsed string In-Reply-To: References: Message-ID: Unfortunately it is not at this time: https://github.com/dateutil/dateutil/issues/125 This improvement is part of a more general improvement to the parser that I'd like to work on soon. It's a bit trickier than just outputting something that can be parsed by strptime, because dateutil's parser can infer dates in formats that are not compatible with strptime (mostly to do with time zones). On 01/24/2017 04:45 PM, Bart Baker wrote: > Hello, > > I was wondering if it is possible to retrieve the inferred format string > from a parsed date str. For example, if I parse a str as follows: > > import dateutil > mystr = '1990/04/22' > parsed = dateutil.parser.parse(mystr) > > Is there any way to retrieve 'YYYY/MM/DD'? I'm assuming the returned > datetime object doesn't retain the information. > > I would appreciate any help that you could offer. > > Thank you, > Bart > _______________________________________________ > Dateutil mailing list > Dateutil at python.org > https://mail.python.org/mailman/listinfo/dateutil > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: OpenPGP digital signature URL: From bartbkr at gmail.com Tue Jan 24 21:00:28 2017 From: bartbkr at gmail.com (Bart Baker) Date: Tue, 24 Jan 2017 21:00:28 -0500 Subject: [Dateutil] Retrieving format string from parsed string In-Reply-To: References: Message-ID: On Tue, Jan 24, 2017 at 6:21 PM, Paul G wrote: > Unfortunately it is not at this time: > > https://github.com/dateutil/dateutil/issues/125 > > This improvement is part of a more general improvement to the parser that I'd like to work on soon. It's a bit trickier than just outputting something that can be parsed by strptime, because dateutil's parser can infer dates in formats that are not compatible with strptime (mostly to do with time zones). OK, thank you. I've subscribed to the github issue. It makes sense why that would be quite difficult! -Bart