PcapPlusPlus  Next
pcpp::X509Timestamp Class Reference

#include <X509Decoder.h>

Public Member Functions

 X509Timestamp (Asn1TimeRecord *timeRecord)
 
std::string toString (const std::string &format="%Y-%m-%d %H:%M:%S", const std::string &timezone="Z", bool includeMilliseconds=false) const
 
std::chrono::system_clock::time_point getTimestamp (const std::string &timezone="Z") const
 

Detailed Description

Represents a timestamp in an X.509 certificate

Constructor & Destructor Documentation

◆ X509Timestamp()

pcpp::X509Timestamp::X509Timestamp ( Asn1TimeRecord timeRecord)
inlineexplicit

Constructs an X509Timestamp from an ASN.1 time record

Parameters
[in]timeRecordPointer to the ASN.1 time record. Note: this class doesn't assume ownership over the record

Member Function Documentation

◆ getTimestamp()

std::chrono::system_clock::time_point pcpp::X509Timestamp::getTimestamp ( const std::string &  timezone = "Z") const

Gets the timestamp as a system_clock::time_point

Parameters
[in]timezoneThe timezone to use in the format of "Z" for UTC or +=HHMM for other timezones (default: "Z" for UTC)
Returns
A time_point representing the timestamp

◆ toString()

std::string pcpp::X509Timestamp::toString ( const std::string &  format = "%Y-%m-%d %H:%M:%S",
const std::string &  timezone = "Z",
bool  includeMilliseconds = false 
) const

Converts the timestamp to a formatted string

Parameters
[in]formatThe format string (strftime format, default: "%Y-%m-%d %H:%M:%S")
[in]timezoneThe timezone to use in the format of "Z" for UTC or +=HHMM for other timezones (default: "Z" for UTC)
[in]includeMillisecondsWhether to include milliseconds in the output
Returns
A formatted string representation of the timestamp