-
Notifications
You must be signed in to change notification settings - Fork 0
/
StdTime.h
97 lines (62 loc) · 2.03 KB
/
StdTime.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef STDTIME_H
#define STDTIME_H
/** @file */
/* The months of the year, to be used by TDateTime */
enum TMonth
{
EJanuary, EFebruary, EMarch, EApril, EMay, EJune,
EJuly, EAugust, ESeptember, EOctober, ENovember, EDecember
};
/* Various useful tables of time and date related information */
extern const char *g_apccDays[];
extern const TInt g_aiDaysPerMonth[];
extern const char *g_apccMonths[];
/* A class designed to hold the date and time in a human readable form */
class TDateTime
{
private:
TInt iYear; /**< The current year */
TMonth iMonth; /**< The month of the current year, starting with EJanuary (0) */
TInt iDay; /**< The day of the current month, starting with 1 */
TInt iHour; /**< The hour of the current day */
TInt iMinute; /**< The minute of the current day */
TInt iSecond; /**< The second of the current minute */
TInt iMilliSecond; /**< The millisecond of the current second */
public:
TDateTime()
{
iYear = iDay = iHour = iMinute = iSecond = iMilliSecond = 0;
iMonth = EJanuary;
}
TDateTime(TInt64 a_iTime);
TDateTime(TInt a_iYear, TMonth a_iMonth, TInt a_iDay, TInt a_iHour, TInt a_iMinute, TInt a_iSecond, TInt a_iMilliSecond);
TInt Year() const { return(iYear); }
TInt Month() const { return(iMonth); }
TInt Day() const { return(iDay); }
TInt DayOfWeek() const;
TInt Hour() const { return(iHour); }
TInt Minute() const { return(iMinute); }
TInt Second() const { return(iSecond); }
TInt MilliSecond() const { return(iMilliSecond); }
static TBool IsLeapYear(TInt a_iYear);
};
class TTime
{
private:
TInt64 iTime; /**< Time since 01.01.01 in microseconds */
TDateTime iDateTime; /**< Internal representation of the time */
private:
void Set(const TDateTime &a_roDateTime);
public:
TTime()
{
iTime = 0;
}
TDateTime DateTime() const { return(iDateTime); }
void HomeTime();
TInt64 Int64() const;
TTime &operator=(const TDateTime &a_roDateTime);
TBool operator==(const TTime &a_roTime) const;
TBool operator>(const TTime &a_roTime) const;
};
#endif /* ! STDTIME_H */