Storycraft: properly support/print timestamps

This commit is contained in:
Brian S. Stephan 2012-07-27 16:51:57 -05:00
parent 033631e5c2
commit adccf69ede
1 changed files with 14 additions and 10 deletions

View File

@ -20,6 +20,8 @@ import random
import re
import time
from datetime import datetime
from dateutil.tz import *
import MySQLdb as mdb
from Module import Module
@ -554,8 +556,8 @@ class Storycraft(Module):
game.status = result['status']
game.owner_nick = result['owner_nick']
game.owner_userhost = result['owner_userhost']
game.start_time = result['start_time']
game.end_time = result['end_time']
game.start_time = result['start_time'].replace(tzinfo=tzlocal())
game.end_time = result['end_time'].replace(tzinfo=tzlocal())
return game
except mdb.Error as e:
@ -567,9 +569,11 @@ class Storycraft(Module):
def _get_game_summary(self, game):
"""Display game info for a general summary."""
status_str = '#{0:d} - created on {1:s} by {2:s}, {3:s}'.format(game.id, game.start_time, game.owner_nick, game.status)
status_str = '#{0:d} - created on {1:s} by {2:s}, {3:s}'.format(game.id,
game.start_time.strftime('%Y/%m/%d %H:%M:%S'),
game.owner_nick, game.status)
if game.status == 'COMPLETED' and game.end_time:
status_str = status_str + ' ({0:s})'.format(game.end_time)
status_str = status_str + ' ({0:s})'.format(game.end_time.strftime('%Y/%m/%d %H:%M:%S'))
elif game.status == 'IN PROGRESS':
lines = self._get_lines_for_game(game.id)
player = self._get_player_by_id(lines[0].player_id)
@ -859,8 +863,8 @@ class Storycraft(Module):
game.status = result['status']
game.owner_nick = result['owner_nick']
game.owner_userhost = result['owner_userhost']
game.start_time = result['start_time']
game.end_time = result['end_time']
game.start_time = result['start_time'].replace(tzinfo=tzlocal())
game.end_time = result['end_time'].replace(tzinfo=tzlocal())
games.append(game)
@ -912,8 +916,8 @@ class Storycraft(Module):
game.status = result['status']
game.owner_nick = result['owner_nick']
game.owner_userhost = result['owner_userhost']
game.start_time = result['start_time']
game.end_time = result['end_time']
game.start_time = result['start_time'].replace(tzinfo=tzlocal())
game.end_time = result['end_time'].replace(tzinfo=tzlocal())
games.append(game)
@ -952,8 +956,8 @@ class Storycraft(Module):
game.status = result['status']
game.owner_nick = result['owner_nick']
game.owner_userhost = result['owner_userhost']
game.start_time = result['start_time']
game.end_time = result['end_time']
game.start_time = result['start_time'].replace(tzinfo=tzlocal())
game.end_time = result['end_time'].replace(tzinfo=tzlocal())
games.append(game)