12e5b6d6dSopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
22e5b6d6dSopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
32e5b6d6dSopenharmony_ci/*
42e5b6d6dSopenharmony_ci*******************************************************************************
52e5b6d6dSopenharmony_ci* Copyright (C) 2007-2012, International Business Machines Corporation and
62e5b6d6dSopenharmony_ci* others. All Rights Reserved.
72e5b6d6dSopenharmony_ci*******************************************************************************
82e5b6d6dSopenharmony_ci*/
92e5b6d6dSopenharmony_ci
102e5b6d6dSopenharmony_ci#include "utypeinfo.h"  // for 'typeid' to work
112e5b6d6dSopenharmony_ci
122e5b6d6dSopenharmony_ci#include "unicode/utypes.h"
132e5b6d6dSopenharmony_ci
142e5b6d6dSopenharmony_ci#if !UCONFIG_NO_FORMATTING
152e5b6d6dSopenharmony_ci
162e5b6d6dSopenharmony_ci#include "unicode/dtrule.h"
172e5b6d6dSopenharmony_ci
182e5b6d6dSopenharmony_ciU_NAMESPACE_BEGIN
192e5b6d6dSopenharmony_ci
202e5b6d6dSopenharmony_ciUOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule)
212e5b6d6dSopenharmony_ci
222e5b6d6dSopenharmony_ciDateTimeRule::DateTimeRule(int32_t month,
232e5b6d6dSopenharmony_ci                           int32_t dayOfMonth,
242e5b6d6dSopenharmony_ci                           int32_t millisInDay,
252e5b6d6dSopenharmony_ci                           TimeRuleType timeType)
262e5b6d6dSopenharmony_ci: fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay),
272e5b6d6dSopenharmony_ci  fDateRuleType(DateTimeRule::DOM), fTimeRuleType(timeType) {
282e5b6d6dSopenharmony_ci}
292e5b6d6dSopenharmony_ci
302e5b6d6dSopenharmony_ciDateTimeRule::DateTimeRule(int32_t month,
312e5b6d6dSopenharmony_ci                           int32_t weekInMonth,
322e5b6d6dSopenharmony_ci                           int32_t dayOfWeek,
332e5b6d6dSopenharmony_ci                           int32_t millisInDay,
342e5b6d6dSopenharmony_ci                           TimeRuleType timeType)
352e5b6d6dSopenharmony_ci: fMonth(month), fDayOfMonth(0), fDayOfWeek(dayOfWeek), fWeekInMonth(weekInMonth), fMillisInDay(millisInDay),
362e5b6d6dSopenharmony_ci  fDateRuleType(DateTimeRule::DOW), fTimeRuleType(timeType) {
372e5b6d6dSopenharmony_ci}
382e5b6d6dSopenharmony_ci
392e5b6d6dSopenharmony_ciDateTimeRule::DateTimeRule(int32_t month,
402e5b6d6dSopenharmony_ci                           int32_t dayOfMonth,
412e5b6d6dSopenharmony_ci                           int32_t dayOfWeek,
422e5b6d6dSopenharmony_ci                           UBool after,
432e5b6d6dSopenharmony_ci                           int32_t millisInDay,
442e5b6d6dSopenharmony_ci                           TimeRuleType timeType)
452e5b6d6dSopenharmony_ci: UObject(),
462e5b6d6dSopenharmony_ci  fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(dayOfWeek), fWeekInMonth(0), fMillisInDay(millisInDay),
472e5b6d6dSopenharmony_ci  fTimeRuleType(timeType) {
482e5b6d6dSopenharmony_ci    if (after) {
492e5b6d6dSopenharmony_ci        fDateRuleType = DateTimeRule::DOW_GEQ_DOM;
502e5b6d6dSopenharmony_ci    } else {
512e5b6d6dSopenharmony_ci        fDateRuleType = DateTimeRule::DOW_LEQ_DOM;
522e5b6d6dSopenharmony_ci    }
532e5b6d6dSopenharmony_ci}
542e5b6d6dSopenharmony_ci
552e5b6d6dSopenharmony_ciDateTimeRule::DateTimeRule(const DateTimeRule& source)
562e5b6d6dSopenharmony_ci: UObject(source),
572e5b6d6dSopenharmony_ci  fMonth(source.fMonth), fDayOfMonth(source.fDayOfMonth), fDayOfWeek(source.fDayOfWeek),
582e5b6d6dSopenharmony_ci  fWeekInMonth(source.fWeekInMonth), fMillisInDay(source.fMillisInDay),
592e5b6d6dSopenharmony_ci  fDateRuleType(source.fDateRuleType), fTimeRuleType(source.fTimeRuleType) {
602e5b6d6dSopenharmony_ci}
612e5b6d6dSopenharmony_ci
622e5b6d6dSopenharmony_ciDateTimeRule::~DateTimeRule() {
632e5b6d6dSopenharmony_ci}
642e5b6d6dSopenharmony_ci
652e5b6d6dSopenharmony_ciDateTimeRule*
662e5b6d6dSopenharmony_ciDateTimeRule::clone() const {
672e5b6d6dSopenharmony_ci    return new DateTimeRule(*this);
682e5b6d6dSopenharmony_ci}
692e5b6d6dSopenharmony_ci
702e5b6d6dSopenharmony_ciDateTimeRule&
712e5b6d6dSopenharmony_ciDateTimeRule::operator=(const DateTimeRule& right) {
722e5b6d6dSopenharmony_ci    if (this != &right) {
732e5b6d6dSopenharmony_ci        fMonth = right.fMonth;
742e5b6d6dSopenharmony_ci        fDayOfMonth = right.fDayOfMonth;
752e5b6d6dSopenharmony_ci        fDayOfWeek = right.fDayOfWeek;
762e5b6d6dSopenharmony_ci        fWeekInMonth = right.fWeekInMonth;
772e5b6d6dSopenharmony_ci        fMillisInDay = right.fMillisInDay;
782e5b6d6dSopenharmony_ci        fDateRuleType = right.fDateRuleType;
792e5b6d6dSopenharmony_ci        fTimeRuleType = right.fTimeRuleType;
802e5b6d6dSopenharmony_ci    }
812e5b6d6dSopenharmony_ci    return *this;
822e5b6d6dSopenharmony_ci}
832e5b6d6dSopenharmony_ci
842e5b6d6dSopenharmony_cibool
852e5b6d6dSopenharmony_ciDateTimeRule::operator==(const DateTimeRule& that) const {
862e5b6d6dSopenharmony_ci    return ((this == &that) ||
872e5b6d6dSopenharmony_ci            (typeid(*this) == typeid(that) &&
882e5b6d6dSopenharmony_ci            fMonth == that.fMonth &&
892e5b6d6dSopenharmony_ci            fDayOfMonth == that.fDayOfMonth &&
902e5b6d6dSopenharmony_ci            fDayOfWeek == that.fDayOfWeek &&
912e5b6d6dSopenharmony_ci            fWeekInMonth == that.fWeekInMonth &&
922e5b6d6dSopenharmony_ci            fMillisInDay == that.fMillisInDay &&
932e5b6d6dSopenharmony_ci            fDateRuleType == that.fDateRuleType &&
942e5b6d6dSopenharmony_ci            fTimeRuleType == that.fTimeRuleType));
952e5b6d6dSopenharmony_ci}
962e5b6d6dSopenharmony_ci
972e5b6d6dSopenharmony_cibool
982e5b6d6dSopenharmony_ciDateTimeRule::operator!=(const DateTimeRule& that) const {
992e5b6d6dSopenharmony_ci    return !operator==(that);
1002e5b6d6dSopenharmony_ci}
1012e5b6d6dSopenharmony_ci
1022e5b6d6dSopenharmony_ciDateTimeRule::DateRuleType
1032e5b6d6dSopenharmony_ciDateTimeRule::getDateRuleType(void) const {
1042e5b6d6dSopenharmony_ci    return fDateRuleType;
1052e5b6d6dSopenharmony_ci}
1062e5b6d6dSopenharmony_ci
1072e5b6d6dSopenharmony_ciDateTimeRule::TimeRuleType
1082e5b6d6dSopenharmony_ciDateTimeRule::getTimeRuleType(void) const {
1092e5b6d6dSopenharmony_ci    return fTimeRuleType;
1102e5b6d6dSopenharmony_ci}
1112e5b6d6dSopenharmony_ci
1122e5b6d6dSopenharmony_ciint32_t
1132e5b6d6dSopenharmony_ciDateTimeRule::getRuleMonth(void) const {
1142e5b6d6dSopenharmony_ci    return fMonth;
1152e5b6d6dSopenharmony_ci}
1162e5b6d6dSopenharmony_ci
1172e5b6d6dSopenharmony_ciint32_t
1182e5b6d6dSopenharmony_ciDateTimeRule::getRuleDayOfMonth(void) const {
1192e5b6d6dSopenharmony_ci    return fDayOfMonth;
1202e5b6d6dSopenharmony_ci}
1212e5b6d6dSopenharmony_ci
1222e5b6d6dSopenharmony_ciint32_t
1232e5b6d6dSopenharmony_ciDateTimeRule::getRuleDayOfWeek(void) const {
1242e5b6d6dSopenharmony_ci    return fDayOfWeek;
1252e5b6d6dSopenharmony_ci}
1262e5b6d6dSopenharmony_ci
1272e5b6d6dSopenharmony_ciint32_t
1282e5b6d6dSopenharmony_ciDateTimeRule::getRuleWeekInMonth(void) const {
1292e5b6d6dSopenharmony_ci    return fWeekInMonth;
1302e5b6d6dSopenharmony_ci}
1312e5b6d6dSopenharmony_ci
1322e5b6d6dSopenharmony_ciint32_t
1332e5b6d6dSopenharmony_ciDateTimeRule::getRuleMillisInDay(void) const {
1342e5b6d6dSopenharmony_ci    return fMillisInDay;
1352e5b6d6dSopenharmony_ci}
1362e5b6d6dSopenharmony_ci
1372e5b6d6dSopenharmony_ciU_NAMESPACE_END
1382e5b6d6dSopenharmony_ci
1392e5b6d6dSopenharmony_ci#endif /* #if !UCONFIG_NO_FORMATTING */
1402e5b6d6dSopenharmony_ci
1412e5b6d6dSopenharmony_ci//eof
142