From: Geoffrey Thomas Date: Sun, 1 Mar 2009 08:48:54 +0000 (-0500) Subject: use time.strptime instead of parsing time ourselves X-Git-Url: https://sipb.mit.edu/gitweb.cgi/snippets/.git/commitdiff_plain/8332cda6d3177a743ff8799670dd123bed5e3269?ds=inline use time.strptime instead of parsing time ourselves --- diff --git a/barn-growl/barn-growl.py b/barn-growl/barn-growl.py index c040de4..5a2bf4a 100755 --- a/barn-growl/barn-growl.py +++ b/barn-growl/barn-growl.py @@ -12,6 +12,7 @@ import select import sys from abstfilter import AbstractConsumer import optparse +import time class Notifier(AbstractConsumer): def __init__(self, usegrowl, usenotify, useprint): @@ -33,7 +34,7 @@ class Notifier(AbstractConsumer): zop = d['opcode'].lower() zsender = d['sender'].lower() zauth = d['auth'].lower() == 'yes' - ztime = ':'.join(d['time'].split(' ')[3].split(':')[0:2]) + ztime = "%02d:%02d" % time.strptime(d['time'])[3:5] zmessage = d['message'] idtuple = (zclass, zinstance, zsender, ztime) id = '%s/\n%s/\n%s\n %s' % idtuple