Botan  1.11.15
src/lib/asn1/asn1_time.h
Go to the documentation of this file.
00001 /*
00002 * ASN.1 Time Representation
00003 * (C) 1999-2007,2012 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_ASN1_TIME_H__
00009 #define BOTAN_ASN1_TIME_H__
00010 
00011 #include <botan/asn1_obj.h>
00012 #include <chrono>
00013 
00014 namespace Botan {
00015 
00016 /**
00017 * X.509 Time
00018 */
00019 class BOTAN_DLL X509_Time : public ASN1_Object
00020    {
00021    public:
00022       void encode_into(class DER_Encoder&) const;
00023       void decode_from(class BER_Decoder&);
00024 
00025       std::string as_string() const;
00026       std::string readable_string() const;
00027       bool time_is_set() const;
00028 
00029       std::string to_string() const { return readable_string(); }
00030 
00031       s32bit cmp(const X509_Time&) const;
00032 
00033       void set_to(const std::string&);
00034       void set_to(const std::string&, ASN1_Tag);
00035 
00036       X509_Time(const std::chrono::system_clock::time_point& time);
00037       X509_Time(const std::string& = "");
00038       X509_Time(const std::string&, ASN1_Tag);
00039    private:
00040       bool passes_sanity_check() const;
00041       u32bit year, month, day, hour, minute, second;
00042       ASN1_Tag tag;
00043    };
00044 
00045 /*
00046 * Comparison Operations
00047 */
00048 bool BOTAN_DLL operator==(const X509_Time&, const X509_Time&);
00049 bool BOTAN_DLL operator!=(const X509_Time&, const X509_Time&);
00050 bool BOTAN_DLL operator<=(const X509_Time&, const X509_Time&);
00051 bool BOTAN_DLL operator>=(const X509_Time&, const X509_Time&);
00052 bool BOTAN_DLL operator<(const X509_Time&, const X509_Time&);
00053 bool BOTAN_DLL operator>(const X509_Time&, const X509_Time&);
00054 
00055 }
00056 
00057 #endif