Ways to get number of seconds from Epoch
M.-A. Lemburg
mal at lemburg.com
Sat May 4 14:05:49 EDT 2002
Mark McEahern wrote:
>
> Mark,
>
> Regarding this format:
>
> [15/Apr/2002:08:28:56 +0200]
>
> I wrote:
>
> > That format seems a little odd:
>
> [brueckd at tbye.com] replied:
> > It is a little odd, but it's also how Common Log Format does timestamps:
> >
> > http://www.bacuslabs.com/WsvlCLF.html
It's an odd format indeed... I wonder why people have to reinvent
new date formats all the time, the ISO format is both eas to read
and easy to parse.
> When you use mx.DateTime.DateTimeFrom on that format, here's what happens:
>
> >>> from mx.DateTime import DateTimeFrom
> >>> s = "[15/Apr/2002:08:28:56 +0200]"
> >>> dt = DateTimeFrom(s)
> >>> str(dt)
> '2002-04-01 02:08:28.00'
>
> So my question is whether that's a format mx.DateTime should support? It's
> easy enough to massage the data so that it's in a more recognizable format
> before passing it to mx.DateTime.
>
> I'm not personally invested in the answer, I just wanted to alert you to a
> question that came up on c.l.py.
I'll see whether the parse can be extended to support this
format as well. The usual problem with this is that it support
*very* many different formats (including partially broken ones),
so extending it is not as easy as you might expect.
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/
More information about the Python-list
mailing list