]>
Commit | Line | Data |
---|---|---|
46f4442e A |
1 | /* |
2 | ******************************************************************************* | |
3 | * Copyright (C) 2007, International Business Machines Corporation and * | |
4 | * others. All Rights Reserved. * | |
5 | ******************************************************************************* | |
6 | */ | |
7 | ||
8 | #include "unicode/utypes.h" | |
9 | ||
10 | #if !UCONFIG_NO_FORMATTING | |
11 | ||
12 | #include "unicode/dtrule.h" | |
13 | ||
14 | U_NAMESPACE_BEGIN | |
15 | ||
16 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule) | |
17 | ||
18 | DateTimeRule::DateTimeRule(int32_t month, | |
19 | int32_t dayOfMonth, | |
20 | int32_t millisInDay, | |
21 | TimeRuleType timeType) | |
22 | : fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay), | |
23 | fDateRuleType(DateTimeRule::DOM), fTimeRuleType(timeType) { | |
24 | } | |
25 | ||
26 | DateTimeRule::DateTimeRule(int32_t month, | |
27 | int32_t weekInMonth, | |
28 | int32_t dayOfWeek, | |
29 | int32_t millisInDay, | |
30 | TimeRuleType timeType) | |
31 | : fMonth(month), fDayOfMonth(0), fDayOfWeek(dayOfWeek), fWeekInMonth(weekInMonth), fMillisInDay(millisInDay), | |
32 | fDateRuleType(DateTimeRule::DOW), fTimeRuleType(timeType) { | |
33 | } | |
34 | ||
35 | DateTimeRule::DateTimeRule(int32_t month, | |
36 | int32_t dayOfMonth, | |
37 | int32_t dayOfWeek, | |
38 | UBool after, | |
39 | int32_t millisInDay, | |
40 | TimeRuleType timeType) | |
41 | : UObject(), | |
42 | fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(dayOfWeek), fWeekInMonth(0), fMillisInDay(millisInDay), | |
43 | fTimeRuleType(timeType) { | |
44 | if (after) { | |
45 | fDateRuleType = DateTimeRule::DOW_GEQ_DOM; | |
46 | } else { | |
47 | fDateRuleType = DateTimeRule::DOW_LEQ_DOM; | |
48 | } | |
49 | } | |
50 | ||
51 | DateTimeRule::DateTimeRule(const DateTimeRule& source) | |
52 | : UObject(source), | |
53 | fMonth(source.fMonth), fDayOfMonth(source.fDayOfMonth), fDayOfWeek(source.fDayOfWeek), | |
54 | fWeekInMonth(source.fWeekInMonth), fMillisInDay(source.fMillisInDay), | |
55 | fDateRuleType(source.fDateRuleType), fTimeRuleType(source.fTimeRuleType) { | |
56 | } | |
57 | ||
58 | DateTimeRule::~DateTimeRule() { | |
59 | } | |
60 | ||
61 | DateTimeRule* | |
62 | DateTimeRule::clone() const { | |
63 | return new DateTimeRule(*this); | |
64 | } | |
65 | ||
66 | DateTimeRule& | |
67 | DateTimeRule::operator=(const DateTimeRule& right) { | |
68 | if (this != &right) { | |
69 | fMonth = right.fMonth; | |
70 | fDayOfMonth = right.fDayOfMonth; | |
71 | fDayOfWeek = right.fDayOfWeek; | |
72 | fWeekInMonth = right.fWeekInMonth; | |
73 | fMillisInDay = right.fMillisInDay; | |
74 | fDateRuleType = right.fDateRuleType; | |
75 | fTimeRuleType = right.fTimeRuleType; | |
76 | } | |
77 | return *this; | |
78 | } | |
79 | ||
80 | UBool | |
81 | DateTimeRule::operator==(const DateTimeRule& that) const { | |
82 | return ((this == &that) || | |
83 | (getDynamicClassID() == that.getDynamicClassID() && | |
84 | fMonth == that.fMonth && | |
85 | fDayOfMonth == that.fDayOfMonth && | |
86 | fDayOfWeek == that.fDayOfWeek && | |
87 | fWeekInMonth == that.fWeekInMonth && | |
88 | fMillisInDay == that.fMillisInDay && | |
89 | fDateRuleType == that.fDateRuleType && | |
90 | fTimeRuleType == that.fTimeRuleType)); | |
91 | } | |
92 | ||
93 | UBool | |
94 | DateTimeRule::operator!=(const DateTimeRule& that) const { | |
95 | return !operator==(that); | |
96 | } | |
97 | ||
98 | DateTimeRule::DateRuleType | |
99 | DateTimeRule::getDateRuleType(void) const { | |
100 | return fDateRuleType; | |
101 | } | |
102 | ||
103 | DateTimeRule::TimeRuleType | |
104 | DateTimeRule::getTimeRuleType(void) const { | |
105 | return fTimeRuleType; | |
106 | } | |
107 | ||
108 | int32_t | |
109 | DateTimeRule::getRuleMonth(void) const { | |
110 | return fMonth; | |
111 | } | |
112 | ||
113 | int32_t | |
114 | DateTimeRule::getRuleDayOfMonth(void) const { | |
115 | return fDayOfMonth; | |
116 | } | |
117 | ||
118 | int32_t | |
119 | DateTimeRule::getRuleDayOfWeek(void) const { | |
120 | return fDayOfWeek; | |
121 | } | |
122 | ||
123 | int32_t | |
124 | DateTimeRule::getRuleWeekInMonth(void) const { | |
125 | return fWeekInMonth; | |
126 | } | |
127 | ||
128 | int32_t | |
129 | DateTimeRule::getRuleMillisInDay(void) const { | |
130 | return fMillisInDay; | |
131 | } | |
132 | ||
133 | U_NAMESPACE_END | |
134 | ||
135 | #endif /* #if !UCONFIG_NO_FORMATTING */ | |
136 | ||
137 | //eof |