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