1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/dtrule.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,139 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* Copyright (C) 2007-2012, International Business Machines Corporation and 1.7 +* others. All Rights Reserved. 1.8 +******************************************************************************* 1.9 +*/ 1.10 + 1.11 +#include "utypeinfo.h" // for 'typeid' to work 1.12 + 1.13 +#include "unicode/utypes.h" 1.14 + 1.15 +#if !UCONFIG_NO_FORMATTING 1.16 + 1.17 +#include "unicode/dtrule.h" 1.18 + 1.19 +U_NAMESPACE_BEGIN 1.20 + 1.21 +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule) 1.22 + 1.23 +DateTimeRule::DateTimeRule(int32_t month, 1.24 + int32_t dayOfMonth, 1.25 + int32_t millisInDay, 1.26 + TimeRuleType timeType) 1.27 +: fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay), 1.28 + fDateRuleType(DateTimeRule::DOM), fTimeRuleType(timeType) { 1.29 +} 1.30 + 1.31 +DateTimeRule::DateTimeRule(int32_t month, 1.32 + int32_t weekInMonth, 1.33 + int32_t dayOfWeek, 1.34 + int32_t millisInDay, 1.35 + TimeRuleType timeType) 1.36 +: fMonth(month), fDayOfMonth(0), fDayOfWeek(dayOfWeek), fWeekInMonth(weekInMonth), fMillisInDay(millisInDay), 1.37 + fDateRuleType(DateTimeRule::DOW), fTimeRuleType(timeType) { 1.38 +} 1.39 + 1.40 +DateTimeRule::DateTimeRule(int32_t month, 1.41 + int32_t dayOfMonth, 1.42 + int32_t dayOfWeek, 1.43 + UBool after, 1.44 + int32_t millisInDay, 1.45 + TimeRuleType timeType) 1.46 +: UObject(), 1.47 + fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(dayOfWeek), fWeekInMonth(0), fMillisInDay(millisInDay), 1.48 + fTimeRuleType(timeType) { 1.49 + if (after) { 1.50 + fDateRuleType = DateTimeRule::DOW_GEQ_DOM; 1.51 + } else { 1.52 + fDateRuleType = DateTimeRule::DOW_LEQ_DOM; 1.53 + } 1.54 +} 1.55 + 1.56 +DateTimeRule::DateTimeRule(const DateTimeRule& source) 1.57 +: UObject(source), 1.58 + fMonth(source.fMonth), fDayOfMonth(source.fDayOfMonth), fDayOfWeek(source.fDayOfWeek), 1.59 + fWeekInMonth(source.fWeekInMonth), fMillisInDay(source.fMillisInDay), 1.60 + fDateRuleType(source.fDateRuleType), fTimeRuleType(source.fTimeRuleType) { 1.61 +} 1.62 + 1.63 +DateTimeRule::~DateTimeRule() { 1.64 +} 1.65 + 1.66 +DateTimeRule* 1.67 +DateTimeRule::clone() const { 1.68 + return new DateTimeRule(*this); 1.69 +} 1.70 + 1.71 +DateTimeRule& 1.72 +DateTimeRule::operator=(const DateTimeRule& right) { 1.73 + if (this != &right) { 1.74 + fMonth = right.fMonth; 1.75 + fDayOfMonth = right.fDayOfMonth; 1.76 + fDayOfWeek = right.fDayOfWeek; 1.77 + fWeekInMonth = right.fWeekInMonth; 1.78 + fMillisInDay = right.fMillisInDay; 1.79 + fDateRuleType = right.fDateRuleType; 1.80 + fTimeRuleType = right.fTimeRuleType; 1.81 + } 1.82 + return *this; 1.83 +} 1.84 + 1.85 +UBool 1.86 +DateTimeRule::operator==(const DateTimeRule& that) const { 1.87 + return ((this == &that) || 1.88 + (typeid(*this) == typeid(that) && 1.89 + fMonth == that.fMonth && 1.90 + fDayOfMonth == that.fDayOfMonth && 1.91 + fDayOfWeek == that.fDayOfWeek && 1.92 + fWeekInMonth == that.fWeekInMonth && 1.93 + fMillisInDay == that.fMillisInDay && 1.94 + fDateRuleType == that.fDateRuleType && 1.95 + fTimeRuleType == that.fTimeRuleType)); 1.96 +} 1.97 + 1.98 +UBool 1.99 +DateTimeRule::operator!=(const DateTimeRule& that) const { 1.100 + return !operator==(that); 1.101 +} 1.102 + 1.103 +DateTimeRule::DateRuleType 1.104 +DateTimeRule::getDateRuleType(void) const { 1.105 + return fDateRuleType; 1.106 +} 1.107 + 1.108 +DateTimeRule::TimeRuleType 1.109 +DateTimeRule::getTimeRuleType(void) const { 1.110 + return fTimeRuleType; 1.111 +} 1.112 + 1.113 +int32_t 1.114 +DateTimeRule::getRuleMonth(void) const { 1.115 + return fMonth; 1.116 +} 1.117 + 1.118 +int32_t 1.119 +DateTimeRule::getRuleDayOfMonth(void) const { 1.120 + return fDayOfMonth; 1.121 +} 1.122 + 1.123 +int32_t 1.124 +DateTimeRule::getRuleDayOfWeek(void) const { 1.125 + return fDayOfWeek; 1.126 +} 1.127 + 1.128 +int32_t 1.129 +DateTimeRule::getRuleWeekInMonth(void) const { 1.130 + return fWeekInMonth; 1.131 +} 1.132 + 1.133 +int32_t 1.134 +DateTimeRule::getRuleMillisInDay(void) const { 1.135 + return fMillisInDay; 1.136 +} 1.137 + 1.138 +U_NAMESPACE_END 1.139 + 1.140 +#endif /* #if !UCONFIG_NO_FORMATTING */ 1.141 + 1.142 +//eof