]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/dtrule.cpp
ICU-511.32.tar.gz
[apple/icu.git] / icuSources / i18n / dtrule.cpp
CommitLineData
46f4442e
A
1/*
2*******************************************************************************
51004dcb 3* Copyright (C) 2007-2012, International Business Machines Corporation and
729e4ab9 4* others. All Rights Reserved.
46f4442e
A
5*******************************************************************************
6*/
7
51004dcb 8#include "utypeinfo.h" // for 'typeid' to work
729e4ab9 9
46f4442e
A
10#include "unicode/utypes.h"
11
12#if !UCONFIG_NO_FORMATTING
13
14#include "unicode/dtrule.h"
15
16U_NAMESPACE_BEGIN
17
18UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule)
19
20DateTimeRule::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}
27
28DateTimeRule::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}
36
37DateTimeRule::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}
52
53DateTimeRule::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}
59
60DateTimeRule::~DateTimeRule() {
61}
62
63DateTimeRule*
64DateTimeRule::clone() const {
65 return new DateTimeRule(*this);
66}
67
68DateTimeRule&
69DateTimeRule::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}
81
82UBool
83DateTimeRule::operator==(const DateTimeRule& that) const {
84 return ((this == &that) ||
729e4ab9 85 (typeid(*this) == typeid(that) &&
46f4442e
A
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}
94
95UBool
96DateTimeRule::operator!=(const DateTimeRule& that) const {
97 return !operator==(that);
98}
99
100DateTimeRule::DateRuleType
101DateTimeRule::getDateRuleType(void) const {
102 return fDateRuleType;
103}
104
105DateTimeRule::TimeRuleType
106DateTimeRule::getTimeRuleType(void) const {
107 return fTimeRuleType;
108}
109
110int32_t
111DateTimeRule::getRuleMonth(void) const {
112 return fMonth;
113}
114
115int32_t
116DateTimeRule::getRuleDayOfMonth(void) const {
117 return fDayOfMonth;
118}
119
120int32_t
121DateTimeRule::getRuleDayOfWeek(void) const {
122 return fDayOfWeek;
123}
124
125int32_t
126DateTimeRule::getRuleWeekInMonth(void) const {
127 return fWeekInMonth;
128}
129
130int32_t
131DateTimeRule::getRuleMillisInDay(void) const {
132 return fMillisInDay;
133}
134
135U_NAMESPACE_END
136
137#endif /* #if !UCONFIG_NO_FORMATTING */
138
139//eof