PoDoFo  1.0.0-dev
Public Member Functions | Static Public Member Functions | List of all members
PoDoFo::PdfDate Class Referencefinal

This class is a date datatype as specified in the PDF reference. More...

#include <PdfDate.h>

Public Member Functions

 PdfDate ()
 Create a PdfDate with epoch time (1/1/1970 00:00:00 UTC)
 
 PdfDate (const std::chrono::seconds &secondsFromEpoch, const nullable< std::chrono::minutes > &minutesFromUTC)
 Create a PdfDate with a specified date/time and offset from UTC. More...
 
const std::chrono::seconds & GetSecondsFromEpoch () const
 
const nullable< std::chrono::minutes > & GetMinutesFromUtc () const
 
PdfString ToString () const
 The value returned by this function can be used in any PdfObject where a date is needed.
 
PdfString ToStringW3C () const
 The value returned is a W3C compliant date representation.
 
bool operator== (const PdfDate &rhs) const
 
bool operator!= (const PdfDate &rhs) const
 

Static Public Member Functions

static PdfDate LocalNow ()
 
static PdfDate UtcNow ()
 
static PdfDate Parse (const std::string_view &dateStr)
 Create a PdfDate with a specified date and time. More...
 
static bool TryParse (const std::string_view &dateStr, PdfDate &date)
 
static PdfDate ParseW3C (const std::string_view &dateStr)
 Create a PdfDate with a specified date and time. More...
 
static bool TryParseW3C (const std::string_view &dateStr, PdfDate &date)
 

Detailed Description

This class is a date datatype as specified in the PDF reference.

You can easily convert from Unix time_t to the PDF time representation and back. Dates like these are used for example in the PDF info dictionary for the creation time and date of the PDF file.

PdfDate objects are immutable.

From the PDF reference:

PDF defines a standard date format, which closely follows that of the international standard ASN.1 (Abstract Syntax Notation One), defined in ISO/IEC 8824 (see the Bibliography). A date is a string of the form (D:YYYYMMDDHHmmSSOHH'mm')

Constructor & Destructor Documentation

◆ PdfDate()

PoDoFo::PdfDate::PdfDate ( const std::chrono::seconds &  secondsFromEpoch,
const nullable< std::chrono::minutes > &  minutesFromUTC 
)

Create a PdfDate with a specified date/time and offset from UTC.

Parameters
secondsFromEpochseconds from epoch (1/1/1970 00:00:00 UTC) \minutesFromUTC Offset in minutes from UTC

Member Function Documentation

◆ GetSecondsFromEpoch()

const std::chrono::seconds& PoDoFo::PdfDate::GetSecondsFromEpoch ( ) const
inline
Returns
the date and time of this PdfDate in seconds since epoch.

◆ Parse()

PdfDate PdfDate::Parse ( const std::string_view &  dateStr)
static

Create a PdfDate with a specified date and time.

Parameters
dateStrthe date and time of this object in PDF format. It has to be a string of in the format "D:YYYYMMDDHHmmSSOHH'mm'"

◆ ParseW3C()

PdfDate PdfDate::ParseW3C ( const std::string_view &  dateStr)
static

Create a PdfDate with a specified date and time.

Parameters
dateStrthe date and time of this object in W3C format. It has to be a string of the format "YYYY-MM-DDTHH:mm:SSOHH:mm"

The documentation for this class was generated from the following files: