summaryrefslogtreecommitdiff
path: root/xfa/fgas/localization/cfx_datetime.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-29 14:50:40 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-29 19:42:25 +0000
commit0cf642f763b1ab8cdb3c52db80cf38e380c82a19 (patch)
tree7ae693182eb52787bf7357d4b36d882811904453 /xfa/fgas/localization/cfx_datetime.h
parentefcae5d85f829618749461617521a076881cc493 (diff)
downloadpdfium-0cf642f763b1ab8cdb3c52db80cf38e380c82a19.tar.xz
Rename CFX_Unitime to CFX_DateTime
The name Unitime did not give any indication of what the class contained. This Cl renames to DateTime to more accurately refect the class holds a date and time. Change-Id: I95f96224822f46a7da46ae39c71d2e23fc16f7d5 Reviewed-on: https://pdfium-review.googlesource.com/3255 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'xfa/fgas/localization/cfx_datetime.h')
-rw-r--r--xfa/fgas/localization/cfx_datetime.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/xfa/fgas/localization/cfx_datetime.h b/xfa/fgas/localization/cfx_datetime.h
new file mode 100644
index 0000000000..d7bfa8d53a
--- /dev/null
+++ b/xfa/fgas/localization/cfx_datetime.h
@@ -0,0 +1,103 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FGAS_LOCALIZATION_CFX_DATETIME_H_
+#define XFA_FGAS_LOCALIZATION_CFX_DATETIME_H_
+
+#include "core/fxcrt/fx_system.h"
+
+bool FX_IsLeapYear(int32_t iYear);
+uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth);
+
+class CFX_DateTime {
+ public:
+ CFX_DateTime()
+ : year_(0),
+ month_(0),
+ day_(0),
+ hour_(0),
+ minute_(0),
+ second_(0),
+ millisecond_(0) {}
+ CFX_DateTime(int32_t year,
+ uint8_t month,
+ uint8_t day,
+ uint8_t hour,
+ uint8_t minute,
+ uint8_t second,
+ uint16_t millisecond)
+ : year_(year),
+ month_(month),
+ day_(day),
+ hour_(hour),
+ minute_(minute),
+ second_(second),
+ millisecond_(millisecond) {}
+
+ void Now();
+
+ void Reset() {
+ year_ = 0;
+ month_ = 0;
+ day_ = 0;
+ hour_ = 0;
+ minute_ = 0;
+ second_ = 0;
+ millisecond_ = 0;
+ }
+
+ bool IsSet() const {
+ return year_ != 0 || month_ != 0 || day_ != 0 || hour_ != 0 ||
+ minute_ != 0 || second_ != 0 || millisecond_ != 0;
+ }
+
+ void SetDate(int32_t year, uint8_t month, uint8_t day) {
+ year_ = year;
+ month_ = month;
+ day_ = day;
+ }
+
+ void SetTime(uint8_t hour,
+ uint8_t minute,
+ uint8_t second,
+ uint16_t millisecond) {
+ hour_ = hour;
+ minute_ = minute;
+ second_ = second;
+ millisecond_ = millisecond;
+ }
+
+ int32_t GetYear() const { return year_; }
+ uint8_t GetMonth() const { return month_; }
+ uint8_t GetDay() const { return day_; }
+ uint8_t GetHour() const { return hour_; }
+ uint8_t GetMinute() const { return minute_; }
+ uint8_t GetSecond() const { return second_; }
+ uint16_t GetMillisecond() const { return millisecond_; }
+ int32_t GetDayOfWeek() const;
+
+ private:
+ int32_t year_;
+ uint8_t month_;
+ uint8_t day_;
+ uint8_t hour_;
+ uint8_t minute_;
+ uint8_t second_;
+ uint16_t millisecond_;
+};
+
+#if _FX_OS_ != _FX_ANDROID_
+#pragma pack(push, 1)
+#endif
+struct FX_TIMEZONE {
+ int8_t tzHour;
+ uint8_t tzMinute;
+};
+#if _FX_OS_ != _FX_ANDROID_
+#pragma pack(pop)
+#endif
+
+#endif // XFA_FGAS_LOCALIZATION_CFX_DATETIME_H_