aboutsummaryrefslogtreecommitdiff
path: root/rpkid/rpki/sundial.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2008-03-27 15:56:51 +0000
committerRob Austein <sra@hactrn.net>2008-03-27 15:56:51 +0000
commite1e5eb6d4541d865b1fcda093c90da8ba93b537b (patch)
tree5c59aa957fe4a29f3cfabc62d363aeb2777f1a0a /rpkid/rpki/sundial.py
parent5024ffbe382f0e279997fdf3f0e3d725d0fa9d50 (diff)
Add revoked_cert table and rototill child_cert revocation code to use
it. Enable MySQLdb exceptions, whack resulting problem with MySQL DATETIME object conversion repeatedly with a blunt object. svn path=/docs/rpki-db-schema.pdf; revision=1564
Diffstat (limited to 'rpkid/rpki/sundial.py')
-rw-r--r--rpkid/rpki/sundial.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/rpkid/rpki/sundial.py b/rpkid/rpki/sundial.py
index a1ffde62..d7394327 100644
--- a/rpkid/rpki/sundial.py
+++ b/rpkid/rpki/sundial.py
@@ -22,6 +22,10 @@ that occur with the more obvious module names.
import datetime as pydatetime
+def now():
+ """Get current timestamp."""
+ return datetime.utcnow()
+
class datetime(pydatetime.datetime):
"""RPKI extensions to standard datetime.datetime class. All work
here is in UTC, so we use naive datetime objects.
@@ -108,8 +112,18 @@ class datetime(pydatetime.datetime):
return cls.fromdatetime(x)
def to_sql(self):
- """Convert to SQL storage format."""
- return self
+ """Convert to SQL storage format.
+
+ There's something whacky going on in the MySQLdb module, it throws
+ range errors when storing a derived type into a DATETIME column.
+ Investigate some day, but for now brute force this by copying the
+ relevant fields into a datetime.datetime for MySQLdb's
+ consumption.
+
+ """
+ return pydatetime.datetime(year = self.year, month = self.month, day = self.day,
+ hour = self.hour, minute = self.minute, second = self.second,
+ microsecond = 0, tzinfo = None)
def later(self, other):
"""Return the later of two timestamps."""
@@ -125,7 +139,7 @@ timedelta = pydatetime.timedelta
if __name__ == "__main__":
- now = datetime.utcnow()
+ now = datetime.now()
print now
print repr(now)
print now.strftime("%s")