intl/icu/source/i18n/dtrule.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial