PoDoFo  1.0.0-dev
PdfDate.h
1 
7 #ifndef PDF_DATE_H
8 #define PDF_DATE_H
9 
10 #include <chrono>
11 
12 #include "PdfDeclarations.h"
13 #include "PdfString.h"
14 
15 namespace PoDoFo {
16 
33 class PODOFO_API PdfDate final
34 {
35 public:
38  PdfDate();
39 
44  PdfDate(const std::chrono::seconds& secondsFromEpoch,
45  const nullable<std::chrono::minutes>& minutesFromUTC);
46 
47 public:
48  static PdfDate LocalNow();
49 
50  static PdfDate UtcNow();
51 
57  static PdfDate Parse(const std::string_view& dateStr);
58  static bool TryParse(const std::string_view& dateStr, PdfDate& date);
59 
65  static PdfDate ParseW3C(const std::string_view& dateStr);
66  static bool TryParseW3C(const std::string_view& dateStr, PdfDate& date);
67 
71  const std::chrono::seconds& GetSecondsFromEpoch() const { return m_SecondsFromEpoch; }
72 
73  const nullable<std::chrono::minutes>& GetMinutesFromUtc() const { return m_MinutesFromUtc; }
74 
78  PdfString ToString() const;
79 
82  PdfString ToStringW3C() const;
83 
84  bool operator==(const PdfDate& rhs) const;
85  bool operator!=(const PdfDate& rhs) const;
86 
87 private:
91  PdfString createStringRepresentation(bool w3cstring) const;
92 
93 private:
94  std::chrono::seconds m_SecondsFromEpoch;
95  nullable<std::chrono::minutes> m_MinutesFromUtc;
96 };
97 
98 };
99 
100 #endif // PDF_DATE_H
SPDX-FileCopyrightText: (C) 2005 Dominik Seichter domseichter@web.de SPDX-FileCopyrightText: (C) 2020...
This class is a date datatype as specified in the PDF reference.
Definition: PdfDate.h:34
PdfDate(const std::chrono::seconds &secondsFromEpoch, const nullable< std::chrono::minutes > &minutesFromUTC)
Create a PdfDate with a specified date/time and offset from UTC.
const std::chrono::seconds & GetSecondsFromEpoch() const
Definition: PdfDate.h:71
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16