1#pragma once
2
3#include <basis/seadTypes.h>
4#include <prim/seadSafeString.h>
5
6namespace sead
7{
8namespace hostio
9{
10class Context;
11class PropertyEvent;
12class Reflexible;
13} // namespace hostio
14
15class CalendarTime
16{
17public:
18#define SEAD_CALENDARTIME_MAKE_CLASS(NAME, VARIABLE_NAME) \
19 class NAME \
20 { \
21 public: \
22 NAME(u32 VARIABLE_NAME) { setValue(VARIABLE_NAME); } \
23 u32 getValue() const { return mValue; } \
24 void setValue(u32 VARIABLE_NAME); \
25 \
26 private: \
27 u32 mValue; \
28 };
29
30 SEAD_CALENDARTIME_MAKE_CLASS(Year, year)
31 SEAD_CALENDARTIME_MAKE_CLASS(Day, day)
32 SEAD_CALENDARTIME_MAKE_CLASS(Hour, hour)
33 SEAD_CALENDARTIME_MAKE_CLASS(Minute, minute)
34 SEAD_CALENDARTIME_MAKE_CLASS(Second, second)
35#undef SEAD_CALENDARTIME_MAKE_CLASS
36
37 class Month
38 {
39 public:
40 Month(u32 month);
41
42 void setValueOneOrigin(u32 month);
43 s32 getValueOneOrigin() const { return mValue; }
44
45 s32 addSelf(u32);
46 s32 subSelf(u32);
47 s32 sub(Month) const;
48
49 static Month makeFromValueOneOrigin(u32 month);
50 static SafeString makeStringOneOrigin(u32 month);
51
52 private:
53 s32 mValue;
54 };
55
56 enum class Week
57 {
58 Sunday,
59 Monday,
60 Tuesday,
61 Wednesday,
62 Thursday,
63 Friday,
64 Saturday,
65 Max,
66 };
67
68 struct Time
69 {
70 Time(const Hour& h = cDefaultHour, const Minute& m = cDefaultMinute,
71 const Second& s = cDefaultSecond);
72
73 Hour mHour;
74 Minute mMinute;
75 Second mSecond;
76 };
77
78 struct Date
79 {
80 Date(const Year& y = cDefaultYear, const Month& month = cDefaultMonth,
81 const Day& day = cDefaultDay);
82
83 void calcWeek();
84
85 Year mYear;
86 Month mMonth;
87 Day mDay;
88 Week mWeek;
89 };
90
91 static const Month cMonth_Jan;
92 static const Month cMonth_Feb;
93 static const Month cMonth_Mar;
94 static const Month cMonth_Apr;
95 static const Month cMonth_May;
96 static const Month cMonth_Jun;
97 static const Month cMonth_Jul;
98 static const Month cMonth_Aug;
99 static const Month cMonth_Sep;
100 static const Month cMonth_Oct;
101 static const Month cMonth_Nov;
102 static const Month cMonth_Dec;
103
104 static const Year cDefaultYear;
105 static const Month cDefaultMonth;
106 static const Day cDefaultDay;
107 static const Hour cDefaultHour;
108 static const Minute cDefaultMinute;
109 static const Second cDefaultSecond;
110
111 CalendarTime(const Date& date, const Time& time);
112 CalendarTime(const Year& year = cDefaultYear, const Month& month = cDefaultMonth,
113 const Day& day = cDefaultDay, const Hour& hour = cDefaultHour,
114 const Minute& minute = cDefaultMinute, const Second& second = cDefaultSecond);
115
116 const Date& getDate() const { return mDate; }
117 const Time& getTime() const { return mTime; }
118
119 void setDate(const Date& date);
120 void setTime(const Time& time) { mTime = time; }
121
122 u32 getYearDays() const;
123 u32 getYear() const { return mDate.mYear.getValue(); }
124 const Month& getMonth() const { return mDate.mMonth; }
125 u32 getDay() const { return mDate.mDay.getValue(); }
126 Week getWeekDay() const { return mDate.mWeek; }
127 u32 getHour() const { return mTime.mHour.getValue(); }
128 u32 getMinute() const { return mTime.mMinute.getValue(); }
129 u32 getSecond() const { return mTime.mSecond.getValue(); }
130
131 void genHostIOMessage(hostio::Context*);
132 void listenHostIOPropertyEvent(const hostio::PropertyEvent*, hostio::Reflexible*);
133
134private:
135 Date mDate;
136 Time mTime;
137
138 static void makeWeekDayNameLabel_(BufferedSafeString* out_span, Week week);
139};
140
141} // namespace sead
142