How to parse this timestamp?
Diez B. Roggisch
deets at nospam.web.de
Wed Mar 12 23:31:30 CET 2008
> I've got timestamps in a file that look like:
> [19-Aug-2007 07:38:43+216ms NZST]
> How can I parse them? I don't see any way to build a strftime()
> format string that can handle the +216ms part. The best I can see is
> tearing it all apart with a regex, but I'm trying to avoid that pain
> if I can.
> (PS: I have no clue why google groups thinks it should put
> "gnu.gcc.help" on the from line)
Then don't use the regexes. Use string.split to separate the string on
the +, then parse the left part with strptime, and usp pytz and
datetime.timedelta to do the rest.
More information about the Python-list