]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/dtrule.cpp
2 *******************************************************************************
3 * Copyright (C) 2007-2012, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
8 #include "utypeinfo.h" // for 'typeid' to work
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_FORMATTING
14 #include "unicode/dtrule.h"
18 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule
)
20 DateTimeRule::DateTimeRule(int32_t month
,
23 TimeRuleType timeType
)
24 : fMonth(month
), fDayOfMonth(dayOfMonth
), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay
),
25 fDateRuleType(DateTimeRule::DOM
), fTimeRuleType(timeType
) {
28 DateTimeRule::DateTimeRule(int32_t month
,
32 TimeRuleType timeType
)
33 : fMonth(month
), fDayOfMonth(0), fDayOfWeek(dayOfWeek
), fWeekInMonth(weekInMonth
), fMillisInDay(millisInDay
),
34 fDateRuleType(DateTimeRule::DOW
), fTimeRuleType(timeType
) {
37 DateTimeRule::DateTimeRule(int32_t month
,
42 TimeRuleType timeType
)
44 fMonth(month
), fDayOfMonth(dayOfMonth
), fDayOfWeek(dayOfWeek
), fWeekInMonth(0), fMillisInDay(millisInDay
),
45 fTimeRuleType(timeType
) {
47 fDateRuleType
= DateTimeRule::DOW_GEQ_DOM
;
49 fDateRuleType
= DateTimeRule::DOW_LEQ_DOM
;
53 DateTimeRule::DateTimeRule(const DateTimeRule
& 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
) {
60 DateTimeRule::~DateTimeRule() {
64 DateTimeRule::clone() const {
65 return new DateTimeRule(*this);
69 DateTimeRule::operator=(const DateTimeRule
& 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
;
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
));
96 DateTimeRule::operator!=(const DateTimeRule
& that
) const {
97 return !operator==(that
);
100 DateTimeRule::DateRuleType
101 DateTimeRule::getDateRuleType(void) const {
102 return fDateRuleType
;
105 DateTimeRule::TimeRuleType
106 DateTimeRule::getTimeRuleType(void) const {
107 return fTimeRuleType
;
111 DateTimeRule::getRuleMonth(void) const {
116 DateTimeRule::getRuleDayOfMonth(void) const {
121 DateTimeRule::getRuleDayOfWeek(void) const {
126 DateTimeRule::getRuleWeekInMonth(void) const {
131 DateTimeRule::getRuleMillisInDay(void) const {
137 #endif /* #if !UCONFIG_NO_FORMATTING */