michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2007-2012, International Business Machines Corporation and michael@0: * others. All Rights Reserved. michael@0: ******************************************************************************* michael@0: */ michael@0: michael@0: #include "utypeinfo.h" // for 'typeid' to work michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/dtrule.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule) michael@0: michael@0: DateTimeRule::DateTimeRule(int32_t month, michael@0: int32_t dayOfMonth, michael@0: int32_t millisInDay, michael@0: TimeRuleType timeType) michael@0: : fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay), michael@0: fDateRuleType(DateTimeRule::DOM), fTimeRuleType(timeType) { michael@0: } michael@0: michael@0: DateTimeRule::DateTimeRule(int32_t month, michael@0: int32_t weekInMonth, michael@0: int32_t dayOfWeek, michael@0: int32_t millisInDay, michael@0: TimeRuleType timeType) michael@0: : fMonth(month), fDayOfMonth(0), fDayOfWeek(dayOfWeek), fWeekInMonth(weekInMonth), fMillisInDay(millisInDay), michael@0: fDateRuleType(DateTimeRule::DOW), fTimeRuleType(timeType) { michael@0: } michael@0: michael@0: DateTimeRule::DateTimeRule(int32_t month, michael@0: int32_t dayOfMonth, michael@0: int32_t dayOfWeek, michael@0: UBool after, michael@0: int32_t millisInDay, michael@0: TimeRuleType timeType) michael@0: : UObject(), michael@0: fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(dayOfWeek), fWeekInMonth(0), fMillisInDay(millisInDay), michael@0: fTimeRuleType(timeType) { michael@0: if (after) { michael@0: fDateRuleType = DateTimeRule::DOW_GEQ_DOM; michael@0: } else { michael@0: fDateRuleType = DateTimeRule::DOW_LEQ_DOM; michael@0: } michael@0: } michael@0: michael@0: DateTimeRule::DateTimeRule(const DateTimeRule& source) michael@0: : UObject(source), michael@0: fMonth(source.fMonth), fDayOfMonth(source.fDayOfMonth), fDayOfWeek(source.fDayOfWeek), michael@0: fWeekInMonth(source.fWeekInMonth), fMillisInDay(source.fMillisInDay), michael@0: fDateRuleType(source.fDateRuleType), fTimeRuleType(source.fTimeRuleType) { michael@0: } michael@0: michael@0: DateTimeRule::~DateTimeRule() { michael@0: } michael@0: michael@0: DateTimeRule* michael@0: DateTimeRule::clone() const { michael@0: return new DateTimeRule(*this); michael@0: } michael@0: michael@0: DateTimeRule& michael@0: DateTimeRule::operator=(const DateTimeRule& right) { michael@0: if (this != &right) { michael@0: fMonth = right.fMonth; michael@0: fDayOfMonth = right.fDayOfMonth; michael@0: fDayOfWeek = right.fDayOfWeek; michael@0: fWeekInMonth = right.fWeekInMonth; michael@0: fMillisInDay = right.fMillisInDay; michael@0: fDateRuleType = right.fDateRuleType; michael@0: fTimeRuleType = right.fTimeRuleType; michael@0: } michael@0: return *this; michael@0: } michael@0: michael@0: UBool michael@0: DateTimeRule::operator==(const DateTimeRule& that) const { michael@0: return ((this == &that) || michael@0: (typeid(*this) == typeid(that) && michael@0: fMonth == that.fMonth && michael@0: fDayOfMonth == that.fDayOfMonth && michael@0: fDayOfWeek == that.fDayOfWeek && michael@0: fWeekInMonth == that.fWeekInMonth && michael@0: fMillisInDay == that.fMillisInDay && michael@0: fDateRuleType == that.fDateRuleType && michael@0: fTimeRuleType == that.fTimeRuleType)); michael@0: } michael@0: michael@0: UBool michael@0: DateTimeRule::operator!=(const DateTimeRule& that) const { michael@0: return !operator==(that); michael@0: } michael@0: michael@0: DateTimeRule::DateRuleType michael@0: DateTimeRule::getDateRuleType(void) const { michael@0: return fDateRuleType; michael@0: } michael@0: michael@0: DateTimeRule::TimeRuleType michael@0: DateTimeRule::getTimeRuleType(void) const { michael@0: return fTimeRuleType; michael@0: } michael@0: michael@0: int32_t michael@0: DateTimeRule::getRuleMonth(void) const { michael@0: return fMonth; michael@0: } michael@0: michael@0: int32_t michael@0: DateTimeRule::getRuleDayOfMonth(void) const { michael@0: return fDayOfMonth; michael@0: } michael@0: michael@0: int32_t michael@0: DateTimeRule::getRuleDayOfWeek(void) const { michael@0: return fDayOfWeek; michael@0: } michael@0: michael@0: int32_t michael@0: DateTimeRule::getRuleWeekInMonth(void) const { michael@0: return fWeekInMonth; michael@0: } michael@0: michael@0: int32_t michael@0: DateTimeRule::getRuleMillisInDay(void) const { michael@0: return fMillisInDay; michael@0: } michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: michael@0: //eof