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