Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2007-2012, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
6 */
8 #include "utypeinfo.h" // for 'typeid' to work
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_FORMATTING
14 #include "unicode/dtrule.h"
16 U_NAMESPACE_BEGIN
18 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule)
20 DateTimeRule::DateTimeRule(int32_t month,
21 int32_t dayOfMonth,
22 int32_t millisInDay,
23 TimeRuleType timeType)
24 : fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay),
25 fDateRuleType(DateTimeRule::DOM), fTimeRuleType(timeType) {
26 }
28 DateTimeRule::DateTimeRule(int32_t month,
29 int32_t weekInMonth,
30 int32_t dayOfWeek,
31 int32_t millisInDay,
32 TimeRuleType timeType)
33 : fMonth(month), fDayOfMonth(0), fDayOfWeek(dayOfWeek), fWeekInMonth(weekInMonth), fMillisInDay(millisInDay),
34 fDateRuleType(DateTimeRule::DOW), fTimeRuleType(timeType) {
35 }
37 DateTimeRule::DateTimeRule(int32_t month,
38 int32_t dayOfMonth,
39 int32_t dayOfWeek,
40 UBool after,
41 int32_t millisInDay,
42 TimeRuleType timeType)
43 : UObject(),
44 fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(dayOfWeek), fWeekInMonth(0), fMillisInDay(millisInDay),
45 fTimeRuleType(timeType) {
46 if (after) {
47 fDateRuleType = DateTimeRule::DOW_GEQ_DOM;
48 } else {
49 fDateRuleType = DateTimeRule::DOW_LEQ_DOM;
50 }
51 }
53 DateTimeRule::DateTimeRule(const DateTimeRule& source)
54 : UObject(source),
55 fMonth(source.fMonth), fDayOfMonth(source.fDayOfMonth), fDayOfWeek(source.fDayOfWeek),
56 fWeekInMonth(source.fWeekInMonth), fMillisInDay(source.fMillisInDay),
57 fDateRuleType(source.fDateRuleType), fTimeRuleType(source.fTimeRuleType) {
58 }
60 DateTimeRule::~DateTimeRule() {
61 }
63 DateTimeRule*
64 DateTimeRule::clone() const {
65 return new DateTimeRule(*this);
66 }
68 DateTimeRule&
69 DateTimeRule::operator=(const DateTimeRule& right) {
70 if (this != &right) {
71 fMonth = right.fMonth;
72 fDayOfMonth = right.fDayOfMonth;
73 fDayOfWeek = right.fDayOfWeek;
74 fWeekInMonth = right.fWeekInMonth;
75 fMillisInDay = right.fMillisInDay;
76 fDateRuleType = right.fDateRuleType;
77 fTimeRuleType = right.fTimeRuleType;
78 }
79 return *this;
80 }
82 UBool
83 DateTimeRule::operator==(const DateTimeRule& that) const {
84 return ((this == &that) ||
85 (typeid(*this) == typeid(that) &&
86 fMonth == that.fMonth &&
87 fDayOfMonth == that.fDayOfMonth &&
88 fDayOfWeek == that.fDayOfWeek &&
89 fWeekInMonth == that.fWeekInMonth &&
90 fMillisInDay == that.fMillisInDay &&
91 fDateRuleType == that.fDateRuleType &&
92 fTimeRuleType == that.fTimeRuleType));
93 }
95 UBool
96 DateTimeRule::operator!=(const DateTimeRule& that) const {
97 return !operator==(that);
98 }
100 DateTimeRule::DateRuleType
101 DateTimeRule::getDateRuleType(void) const {
102 return fDateRuleType;
103 }
105 DateTimeRule::TimeRuleType
106 DateTimeRule::getTimeRuleType(void) const {
107 return fTimeRuleType;
108 }
110 int32_t
111 DateTimeRule::getRuleMonth(void) const {
112 return fMonth;
113 }
115 int32_t
116 DateTimeRule::getRuleDayOfMonth(void) const {
117 return fDayOfMonth;
118 }
120 int32_t
121 DateTimeRule::getRuleDayOfWeek(void) const {
122 return fDayOfWeek;
123 }
125 int32_t
126 DateTimeRule::getRuleWeekInMonth(void) const {
127 return fWeekInMonth;
128 }
130 int32_t
131 DateTimeRule::getRuleMillisInDay(void) const {
132 return fMillisInDay;
133 }
135 U_NAMESPACE_END
137 #endif /* #if !UCONFIG_NO_FORMATTING */
139 //eof