PoDoFo 1.2.0
Loading...
Searching...
No Matches
PdfDate.h
1// SPDX-FileCopyrightText: 2005 Dominik Seichter <domseichter@web.de>
2// SPDX-FileCopyrightText: 2020 Francesco Pretto <ceztko@gmail.com>
3// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
4
5#ifndef PDF_DATE_H
6#define PDF_DATE_H
7
8#include <chrono>
9
10#include "PdfDeclarations.h"
11#include "PdfString.h"
12
13namespace PoDoFo {
14
30class PODOFO_API PdfDate final
31{
32public:
34 PdfDate();
35
39 PdfDate(const std::chrono::seconds& secondsFromEpoch,
41
42public:
43 static PdfDate LocalNow();
44
45 static PdfDate UtcNow();
46
51 static PdfDate Parse(const std::string_view& dateStr);
52 static bool TryParse(const std::string_view& dateStr, PdfDate& date);
53
58 static PdfDate ParseW3C(const std::string_view& dateStr);
59 static bool TryParseW3C(const std::string_view& dateStr, PdfDate& date);
60
63 const std::chrono::seconds& GetSecondsFromEpoch() const { return m_SecondsFromEpoch; }
64
65 const nullable<std::chrono::minutes>& GetMinutesFromUtc() const { return m_MinutesFromUtc; }
66
69 PdfString ToString() const;
70
72 PdfString ToStringW3C() const;
73
74 bool operator==(const PdfDate& rhs) const;
75 bool operator!=(const PdfDate& rhs) const;
76
77private:
80 PdfString createStringRepresentation(bool w3cstring) const;
81
82private:
83 std::chrono::seconds m_SecondsFromEpoch;
84 nullable<std::chrono::minutes> m_MinutesFromUtc;
85};
86
87};
88
89#endif // PDF_DATE_H
This file should be included as the FIRST file in every header of PoDoFo lib.
This class is a date datatype as specified in the PDF reference.
Definition PdfDate.h:31
const std::chrono::seconds & GetSecondsFromEpoch() const
Definition PdfDate.h:63
PdfDate(const std::chrono::seconds &secondsFromEpoch, const nullable< std::chrono::minutes > &minutesFromUTC)
Create a PdfDate with a specified date/time and offset from UTC.
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:30
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13