jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 1 | // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_CPDFSDK_DATETIME_H_ |
| 8 | #define FPDFSDK_CPDFSDK_DATETIME_H_ |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 9 | |
Dan Sinclair | 698aed7 | 2017-09-26 16:24:49 -0400 | [diff] [blame] | 10 | #if _FX_OS_ == _FX_OS_ANDROID_ |
Dan Sinclair | 85c8e7f | 2016-11-21 13:50:32 -0500 | [diff] [blame] | 11 | #include <time.h> |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 12 | #else |
| 13 | #include <ctime> |
| 14 | #endif |
| 15 | |
| 16 | #include "fpdfsdk/cfx_systemhandler.h" |
| 17 | |
| 18 | class CPDFSDK_DateTime { |
| 19 | public: |
| 20 | CPDFSDK_DateTime(); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 21 | explicit CPDFSDK_DateTime(const ByteString& dtStr); |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 22 | explicit CPDFSDK_DateTime(const FX_SYSTEMTIME& st); |
| 23 | CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime); |
| 24 | |
| 25 | bool operator==(const CPDFSDK_DateTime& datetime) const; |
| 26 | bool operator!=(const CPDFSDK_DateTime& datetime) const; |
| 27 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 28 | CPDFSDK_DateTime& FromPDFDateTimeString(const ByteString& dtStr); |
| 29 | ByteString ToCommonDateTimeString(); |
| 30 | ByteString ToPDFDateTimeString(); |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 31 | void ToSystemTime(FX_SYSTEMTIME& st); |
| 32 | time_t ToTime_t() const; |
| 33 | CPDFSDK_DateTime ToGMT() const; |
| 34 | CPDFSDK_DateTime& AddDays(short days); |
| 35 | CPDFSDK_DateTime& AddSeconds(int seconds); |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 36 | void ResetDateTime(); |
| 37 | |
| 38 | private: |
tsepez | b31ca71 | 2016-09-13 18:10:13 -0700 | [diff] [blame] | 39 | int16_t m_year; |
| 40 | uint8_t m_month; |
| 41 | uint8_t m_day; |
| 42 | uint8_t m_hour; |
| 43 | uint8_t m_minute; |
| 44 | uint8_t m_second; |
| 45 | int8_t m_tzHour; |
| 46 | uint8_t m_tzMinute; |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 49 | #endif // FPDFSDK_CPDFSDK_DATETIME_H_ |