]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/dtrule.cpp
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2007-2012, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
10 #include "utypeinfo.h" // for 'typeid' to work
12 #include "unicode/utypes.h"
14 #if !UCONFIG_NO_FORMATTING
16 #include "unicode/dtrule.h"
20 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule
)
22 DateTimeRule::DateTimeRule(int32_t month
,
25 TimeRuleType timeType
)
26 : fMonth(month
), fDayOfMonth(dayOfMonth
), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay
),
27 fDateRuleType(DateTimeRule::DOM
), fTimeRuleType(timeType
) {
30 DateTimeRule::DateTimeRule(int32_t month
,
34 TimeRuleType timeType
)
35 : fMonth(month
), fDayOfMonth(0), fDayOfWeek(dayOfWeek
), fWeekInMonth(weekInMonth
), fMillisInDay(millisInDay
),
36 fDateRuleType(DateTimeRule::DOW
), fTimeRuleType(timeType
) {
39 DateTimeRule::DateTimeRule(int32_t month
,
44 TimeRuleType timeType
)
46 fMonth(month
), fDayOfMonth(dayOfMonth
), fDayOfWeek(dayOfWeek
), fWeekInMonth(0), fMillisInDay(millisInDay
),
47 fTimeRuleType(timeType
) {
49 fDateRuleType
= DateTimeRule::DOW_GEQ_DOM
;
51 fDateRuleType
= DateTimeRule::DOW_LEQ_DOM
;
55 DateTimeRule::DateTimeRule(const DateTimeRule
& source
)
57 fMonth(source
.fMonth
), fDayOfMonth(source
.fDayOfMonth
), fDayOfWeek(source
.fDayOfWeek
),
58 fWeekInMonth(source
.fWeekInMonth
), fMillisInDay(source
.fMillisInDay
),
59 fDateRuleType(source
.fDateRuleType
), fTimeRuleType(source
.fTimeRuleType
) {
62 DateTimeRule::~DateTimeRule() {
66 DateTimeRule::clone() const {
67 return new DateTimeRule(*this);
71 DateTimeRule::operator=(const DateTimeRule
& right
) {
73 fMonth
= right
.fMonth
;
74 fDayOfMonth
= right
.fDayOfMonth
;
75 fDayOfWeek
= right
.fDayOfWeek
;
76 fWeekInMonth
= right
.fWeekInMonth
;
77 fMillisInDay
= right
.fMillisInDay
;
78 fDateRuleType
= right
.fDateRuleType
;
79 fTimeRuleType
= right
.fTimeRuleType
;
85 DateTimeRule::operator==(const DateTimeRule
& that
) const {
86 return ((this == &that
) ||
87 (typeid(*this) == typeid(that
) &&
88 fMonth
== that
.fMonth
&&
89 fDayOfMonth
== that
.fDayOfMonth
&&
90 fDayOfWeek
== that
.fDayOfWeek
&&
91 fWeekInMonth
== that
.fWeekInMonth
&&
92 fMillisInDay
== that
.fMillisInDay
&&
93 fDateRuleType
== that
.fDateRuleType
&&
94 fTimeRuleType
== that
.fTimeRuleType
));
98 DateTimeRule::operator!=(const DateTimeRule
& that
) const {
99 return !operator==(that
);
102 DateTimeRule::DateRuleType
103 DateTimeRule::getDateRuleType(void) const {
104 return fDateRuleType
;
107 DateTimeRule::TimeRuleType
108 DateTimeRule::getTimeRuleType(void) const {
109 return fTimeRuleType
;
113 DateTimeRule::getRuleMonth(void) const {
118 DateTimeRule::getRuleDayOfMonth(void) const {
123 DateTimeRule::getRuleDayOfWeek(void) const {
128 DateTimeRule::getRuleWeekInMonth(void) const {
133 DateTimeRule::getRuleMillisInDay(void) const {
139 #endif /* #if !UCONFIG_NO_FORMATTING */