]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Add methods to return the time (create or start) in epoch seconds.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 9 Sep 2012 21:02:52 +0000 (17:02 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 9 Sep 2012 21:02:52 +0000 (17:02 -0400)
xonstat/models.py

index 6b29c2cc9c998f2de698d7bcf617dc6dc65a8228..b6ebca1b145c212170c0a287df654c3440b42bab 100644 (file)
@@ -3,6 +3,7 @@ import logging
 import math
 import sqlalchemy
 import sqlalchemy.sql.functions as sfunc
+from calendar import timegm
 from datetime import timedelta
 from sqlalchemy.orm import mapper
 from sqlalchemy.orm import scoped_session
@@ -70,6 +71,9 @@ class Server(object):
     def fuzzy_date(self):
         return pretty_date(self.create_dt)
 
+    def epoch(self):
+        return timegm(self.create_dt.timetuple())
+
 
 class Map(object):
     def __init__(self, name=None):
@@ -84,6 +88,10 @@ class Map(object):
     def fuzzy_date(self):
         return pretty_date(self.create_dt)
 
+    def epoch(self):
+        return timegm(self.create_dt.timetuple())
+
+
 class Game(object):
     def __init__(self, game_id=None, start_dt=None, game_type_cd=None, 
             server_id=None, map_id=None, winner=None):
@@ -103,6 +111,9 @@ class Game(object):
     def fuzzy_date(self):
         return pretty_date(self.start_dt)
 
+    def epoch(self):
+        return timegm(self.start_dt.timetuple())
+
 
 class PlayerGameStat(object):
     def __init__(self, player_game_stat_id=None, create_dt=None):