Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_datetime.h
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
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
7#ifndef CORE_FXCRT_CFX_DATETIME_H_
8#define CORE_FXCRT_CFX_DATETIME_H_
9
10#include <stdint.h>
11
12bool FX_IsLeapYear(int32_t iYear);
13uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth);
14
16 public:
17 static CFX_DateTime Now(); // Accurate to seconds, subject to test overrides.
18
19 CFX_DateTime() = default;
20 CFX_DateTime(int32_t year,
21 uint8_t month,
22 uint8_t day,
23 uint8_t hour,
24 uint8_t minute,
25 uint8_t second,
26 uint16_t millisecond)
27 : year_(year),
28 month_(month),
29 day_(day),
30 hour_(hour),
31 minute_(minute),
32 second_(second),
33 millisecond_(millisecond) {}
34
35 void Reset() {
36 year_ = 0;
37 month_ = 0;
38 day_ = 0;
39 hour_ = 0;
40 minute_ = 0;
41 second_ = 0;
42 millisecond_ = 0;
43 }
44
45 bool IsSet() const {
46 return year_ != 0 || month_ != 0 || day_ != 0 || hour_ != 0 ||
47 minute_ != 0 || second_ != 0 || millisecond_ != 0;
48 }
49
50 void SetDate(int32_t year, uint8_t month, uint8_t day) {
51 year_ = year;
52 month_ = month;
53 day_ = day;
54 }
55
56 void SetTime(uint8_t hour,
57 uint8_t minute,
58 uint8_t second,
59 uint16_t millisecond) {
60 hour_ = hour;
61 minute_ = minute;
62 second_ = second;
63 millisecond_ = millisecond;
64 }
65
66 int32_t GetYear() const { return year_; }
67 uint8_t GetMonth() const { return month_; }
68 uint8_t GetDay() const { return day_; }
69 uint8_t GetHour() const { return hour_; }
70 uint8_t GetMinute() const { return minute_; }
71 uint8_t GetSecond() const { return second_; }
72 uint16_t GetMillisecond() const { return millisecond_; }
73 int32_t GetDayOfWeek() const;
74
75 bool operator==(const CFX_DateTime& other) const;
76
77 private:
78 int32_t year_ = 0;
79 uint8_t month_ = 0;
80 uint8_t day_ = 0;
81 uint8_t hour_ = 0;
82 uint8_t minute_ = 0;
83 uint8_t second_ = 0;
84 uint16_t millisecond_ = 0;
85};
86
87#endif // CORE_FXCRT_CFX_DATETIME_H_
bool FX_IsLeapYear(int32_t iYear)
uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth)
int32_t GetYear() const
CFX_DateTime()=default
static CFX_DateTime Now()
void SetDate(int32_t year, uint8_t month, uint8_t day)
uint8_t GetSecond() const
uint8_t GetHour() const
uint8_t GetDay() const
int32_t GetDayOfWeek() const
bool IsSet() const
uint8_t GetMinute() const
void SetTime(uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond)
bool operator==(const CFX_DateTime &other) const
CFX_DateTime(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond)
uint16_t GetMillisecond() const
uint8_t GetMonth() const
time_t FXSYS_time(time_t *tloc)
struct tm * FXSYS_localtime(const time_t *tp)