diff options
author | Rob Austein <sra@hactrn.net> | 2011-04-21 22:01:02 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2011-04-21 22:01:02 +0000 |
commit | 03996ad7a39896f454d6bed6837ef459362adac4 (patch) | |
tree | 5561e6337b00fb1c90c683989fefb62eca6fd8de | |
parent | 2967a98e9e6b1d7f5061e30441f801631c1750fa (diff) |
Add .fromOpenSSL() constructor.
svn path=/rpkid/rpki/sundial.py; revision=3783
-rw-r--r-- | rpkid/rpki/sundial.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/rpkid/rpki/sundial.py b/rpkid/rpki/sundial.py index d9cac459..63b3f2e2 100644 --- a/rpkid/rpki/sundial.py +++ b/rpkid/rpki/sundial.py @@ -15,7 +15,7 @@ inspection of the datetime module, to wit: $Id$ -Copyright (C) 2009--2010 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2011 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -146,6 +146,16 @@ class datetime(pydatetime.datetime): return cls.combine(x.date(), x.time()) @classmethod + def fromOpenSSL(cls, x): + """ + Convert from the format OpenSSL's command line tool uses into this + subclass. May require rewriting if we run into locale problems. + """ + if x.startswith("notBefore=") or x.startswith("notAfter="): + x = x.partition("=")[2] + return cls.strptime(x, "%b %d %H:%M:%S %Y GMT") + + @classmethod def from_sql(cls, x): """ Convert from SQL storage format. |