PcapPlusPlus  Next
pcpp::Asn1TimeRecord Class Reference

#include <Asn1Codec.h>

Inheritance diagram for pcpp::Asn1TimeRecord:
pcpp::Asn1PrimitiveRecord pcpp::Asn1Record pcpp::Asn1GeneralizedTimeRecord pcpp::Asn1UtcTimeRecord

Public Member Functions

std::chrono::system_clock::time_point getValue (const std::string &timezone="Z") const
 
std::string getValueAsString (const std::string &format="%Y-%m-%d %H:%M:%S", const std::string &timezone="Z", bool includeMilliseconds=false) const
 
- Public Member Functions inherited from pcpp::Asn1Record
std::vector< uint8_t > encode () const
 
Asn1TagClass getTagClass () const
 
bool isConstructed () const
 
Asn1UniversalTagType getUniversalTagType () const
 
uint8_t getTagType () const
 
size_t getValueLength () const
 
size_t getTotalLength () const
 
std::string toString () const
 
template<class Asn1RecordType >
Asn1RecordType * castAs ()
 

Additional Inherited Members

- Static Public Member Functions inherited from pcpp::Asn1Record
static std::unique_ptr< Asn1Recorddecode (const uint8_t *data, size_t dataLen, bool lazy=true)
 
- Protected Member Functions inherited from pcpp::Asn1Record
virtual void decodeValue (uint8_t const *data) const =0
 Decodes the record value from a byte array into the mutable cache variables. This method is marked as const as it can be called on a const instance of the record for lazy decoding.
 
virtual std::vector< uint8_t > encodeValue () const =0
 Encodes the record value into a byte array Prefer using encodeValueSafe() to ensure the value is decoded first if needed.
 
std::vector< uint8_t > encodeValueSafe () const
 Encodes the record value into a byte array, ensuring that the value is decoded first if needed.
 

Detailed Description

An abstract class for representing ASN.1 time records (UTCTime and GeneralizedTime). This class is not instantiable, users should use either Asn1UtcTimeRecord or Asn1GeneralizedTimeRecord

Member Function Documentation

◆ getValue()

std::chrono::system_clock::time_point pcpp::Asn1TimeRecord::getValue ( const std::string &  timezone = "Z") const
inline
Parameters
[in]timezoneA timezone string - should be in the format of "Z" for UTC or +=HHMM for other timezones. The default value is UTC
Returns
The time-point value of this record
Exceptions
std::invalid_argumentif timezone is not in the correct format

◆ getValueAsString()

std::string pcpp::Asn1TimeRecord::getValueAsString ( const std::string &  format = "%Y-%m-%d %H:%M:%S",
const std::string &  timezone = "Z",
bool  includeMilliseconds = false 
) const
Parameters
[in]formatRequested value format
[in]timezoneA timezone string - should be in the format of "Z" for UTC or +=HHMM for other timezones. The default value is UTC
[in]includeMillisecondsShould Include milliseconds in the returned string
Returns
The value as string
Exceptions
std::invalid_argumentif timezone is not in the correct format