Coverage Report

Created: 2025-06-24 06:43

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