Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76387

Re: get the min date from a list

References <mailman.12997.1408025456.18130.python-list@python.org> <lslj31$5hh$2@dont-email.me>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-08-15 15:13 -0600
Subject Re: get the min date from a list
Newsgroups comp.lang.python
Message-ID <mailman.13041.1408137277.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Aug 15, 2014 at 12:21 PM, Denis McMahon
<denismfmcmahon@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).

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: get the min date from a list luofeiyu <elearn2014@gmail.com> - 2014-08-14 22:10 +0800
  Re: get the min date from a list Marko Rauhamaa <marko@pacujo.net> - 2014-08-14 20:19 +0300
  Re: get the min date from a list Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 18:21 +0000
    Re: get the min date from a list Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-15 21:31 +0100
    Re: get the min date from a list Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-15 15:13 -0600

csiph-web