get the min date from a list

Ian Kelly ian.g.kelly at gmail.com
Fri Aug 15 17:13:49 EDT 2014


On Fri, Aug 15, 2014 at 12:21 PM, Denis McMahon
<denismfmcmahon at gmail.com> wrote:
> Output is a sorted list of the actual times and the UTC equivalents of
> all the times in the original list. Note that I had to edit several
> strings in your times list to ensure they were all in identical format: I
> added leading 0s to numeric values in some strings, deleted extra spaces
> in some strings, deleted extraneous information after the tz offset in
> some strings. When feeding strings to a parsing function such as strptime
> () it is critically important that the format specifier matches the input
> data.

>>> datetime.strptime("Mon,   9\t\t\tAug\n2014\r7:36:46\f-0700", "%a, %d %b %Y %H:%M:%S %z")
datetime.datetime(2014, 8, 9, 7, 36, 46,
tzinfo=datetime.timezone(datetime.timedelta(-1, 61200)))

strptime doesn't seem to care about variations in whitespace as long
as some is present, or missing leading zeroes (although it does throw
an error if the time zone offset is only 3 digits).



More information about the Python-list mailing list