From d605f895648863efcb6022a048591630d186a6a1 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 8 Sep 2010 01:08:23 +0800 Subject: [PATCH] OnGame: Make sure time can't fail and report erro --- pyfpdb/OnGameToFpdb.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pyfpdb/OnGameToFpdb.py b/pyfpdb/OnGameToFpdb.py index ecdc6cda..e1db196e 100755 --- a/pyfpdb/OnGameToFpdb.py +++ b/pyfpdb/OnGameToFpdb.py @@ -216,11 +216,14 @@ class OnGame(HandHistoryConverter): #hand.startTime = time.strptime(m.group('DATETIME'), "%a %b %d %H:%M:%S GMT%z %Y") # Stupid library doesn't seem to support %z (http://docs.python.org/library/time.html?highlight=strptime#time.strptime) # So we need to re-interpret te string to be useful - m1 = self.re_DateTime.finditer(info[key]) - for a in m1: + a = self.re_DateTime.search(info[key]) + if a: datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'),a.group('M'), a.group('D'), a.group('H'),a.group('MIN'),a.group('S')) tzoffset = a.group('OFFSET') - # TODO: Manually adjust time against OFFSET + else: + datetimestr = "2010/01/01 01:01:01" + log.error(_("readHandInfo: DATETIME not matched: '%s'" % info[key])) + # TODO: Manually adjust time against OFFSET hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%b/%d %H:%M:%S") # also timezone at end, e.g. " ET" hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, tzoffset, "UTC") if key == 'HID':