diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /intl/icu/source/i18n/dtrule.cpp | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | intl/icu/source/i18n/dtrule.cpp | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/intl/icu/source/i18n/dtrule.cpp b/intl/icu/source/i18n/dtrule.cpp new file mode 100644 index 0000000000..7322cbfdad --- /dev/null +++ b/intl/icu/source/i18n/dtrule.cpp @@ -0,0 +1,141 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +/* +******************************************************************************* +* Copyright (C) 2007-2012, International Business Machines Corporation and +* others. All Rights Reserved. +******************************************************************************* +*/ + +#include "utypeinfo.h" // for 'typeid' to work + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING + +#include "unicode/dtrule.h" + +U_NAMESPACE_BEGIN + +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule) + +DateTimeRule::DateTimeRule(int32_t month, + int32_t dayOfMonth, + int32_t millisInDay, + TimeRuleType timeType) +: fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay), + fDateRuleType(DateTimeRule::DOM), fTimeRuleType(timeType) { +} + +DateTimeRule::DateTimeRule(int32_t month, + int32_t weekInMonth, + int32_t dayOfWeek, + int32_t millisInDay, + TimeRuleType timeType) +: fMonth(month), fDayOfMonth(0), fDayOfWeek(dayOfWeek), fWeekInMonth(weekInMonth), fMillisInDay(millisInDay), + fDateRuleType(DateTimeRule::DOW), fTimeRuleType(timeType) { +} + +DateTimeRule::DateTimeRule(int32_t month, + int32_t dayOfMonth, + int32_t dayOfWeek, + UBool after, + int32_t millisInDay, + TimeRuleType timeType) +: UObject(), + fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(dayOfWeek), fWeekInMonth(0), fMillisInDay(millisInDay), + fTimeRuleType(timeType) { + if (after) { + fDateRuleType = DateTimeRule::DOW_GEQ_DOM; + } else { + fDateRuleType = DateTimeRule::DOW_LEQ_DOM; + } +} + +DateTimeRule::DateTimeRule(const DateTimeRule& source) +: UObject(source), + fMonth(source.fMonth), fDayOfMonth(source.fDayOfMonth), fDayOfWeek(source.fDayOfWeek), + fWeekInMonth(source.fWeekInMonth), fMillisInDay(source.fMillisInDay), + fDateRuleType(source.fDateRuleType), fTimeRuleType(source.fTimeRuleType) { +} + +DateTimeRule::~DateTimeRule() { +} + +DateTimeRule* +DateTimeRule::clone() const { + return new DateTimeRule(*this); +} + +DateTimeRule& +DateTimeRule::operator=(const DateTimeRule& right) { + if (this != &right) { + fMonth = right.fMonth; + fDayOfMonth = right.fDayOfMonth; + fDayOfWeek = right.fDayOfWeek; + fWeekInMonth = right.fWeekInMonth; + fMillisInDay = right.fMillisInDay; + fDateRuleType = right.fDateRuleType; + fTimeRuleType = right.fTimeRuleType; + } + return *this; +} + +bool +DateTimeRule::operator==(const DateTimeRule& that) const { + return ((this == &that) || + (typeid(*this) == typeid(that) && + fMonth == that.fMonth && + fDayOfMonth == that.fDayOfMonth && + fDayOfWeek == that.fDayOfWeek && + fWeekInMonth == that.fWeekInMonth && + fMillisInDay == that.fMillisInDay && + fDateRuleType == that.fDateRuleType && + fTimeRuleType == that.fTimeRuleType)); +} + +bool +DateTimeRule::operator!=(const DateTimeRule& that) const { + return !operator==(that); +} + +DateTimeRule::DateRuleType +DateTimeRule::getDateRuleType() const { + return fDateRuleType; +} + +DateTimeRule::TimeRuleType +DateTimeRule::getTimeRuleType() const { + return fTimeRuleType; +} + +int32_t +DateTimeRule::getRuleMonth() const { + return fMonth; +} + +int32_t +DateTimeRule::getRuleDayOfMonth() const { + return fDayOfMonth; +} + +int32_t +DateTimeRule::getRuleDayOfWeek() const { + return fDayOfWeek; +} + +int32_t +DateTimeRule::getRuleWeekInMonth() const { + return fWeekInMonth; +} + +int32_t +DateTimeRule::getRuleMillisInDay() const { + return fMillisInDay; +} + +U_NAMESPACE_END + +#endif /* #if !UCONFIG_NO_FORMATTING */ + +//eof |