1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef TYPE_H 17 #define TYPE_H 18 19 /** 20 * @addtogroup I18N 21 * @{ 22 * 23 * @brief Provides functions related to internationalization (i18n), with which you can format date, time and numbers. 24 * 25 * @since 2.2 26 * @version 1.0 27 */ 28 29 /** 30 * @file Types.h 31 * 32 * @brief Declares enumerated types of time, date, and number formatting. 33 * 34 * @since 2.2 35 * @version 1.0 36 */ 37 38 #define CONST_CAST const_cast<char *> 39 #define CHAR_CAST reinterpret_cast<char const *> 40 41 #include <string> 42 43 namespace OHOS { 44 namespace I18N { 45 /** 46 * @brief Enumerates formatting statuses. 47 * 48 * @since 2.2 49 * @version 1.0 50 */ 51 enum I18nStatus { 52 /* Success */ 53 ISUCCESS = 0, 54 55 /* Error */ 56 IERROR 57 }; 58 59 /** 60 * @brief Enumerates number formatting types. 61 * 62 * @since 2.2 63 * @version 1.0 64 */ 65 enum NumberFormatType { 66 /* Formats a number into a decimal. */ 67 DECIMAL, 68 69 /* Formats a number into a percentage. */ 70 PERCENT 71 }; 72 73 /** 74 * @brief Enumerates date formatting patterns. 75 * 76 * @since 2.2 77 * @version 1.0 78 */ 79 enum AvailableDateTimeFormatPattern { 80 /* Displays hour, minute, and second in 12-hour format. */ 81 HOUR12_MINUTE_SECOND, 82 83 /* Displays hour, minute, and second in 24-hour format. */ 84 HOUR24_MINUTE_SECOND, 85 86 /* Displays hour, minute, and second in the default time used in a country/region. */ 87 HOUR_MINUTE_SECOND, 88 89 /* Displays hour and minute in 12-hour format. */ 90 HOUR12_MINUTE, 91 92 /* Displays hour and minute in 24-hour format. */ 93 HOUR24_MINUTE, 94 95 /* Displays hour and minute in the default time format used in a country/region. */ 96 HOUR_MINUTE, 97 98 /* Displays month (abbreviated) and day of the week, and day. */ 99 ABBR_MONTH_WEEKDAY_DAY, 100 101 /* Displays month (abbreviated) and day. */ 102 ABBR_MONTH_DAY, 103 104 /* Display year, month, day, and day of the week, for example, Friday December 18, 2020. */ 105 FULL, 106 107 /* Displays year, month, and day, for example, Dec 18, 2020 */ 108 MEDIUM, 109 110 /* Displays year, month, and day in numeric pattern, for example, 12/18/2020. */ 111 SHORT, 112 113 /* Displays year, month (abbreviated), day of the week (abbreviated), and day. */ 114 YEAR_ABBR_MONTH_ABBR_WEEKDAY_DAY, 115 116 /* Displays year, month (wide), day of the week (abbreviated), and day. */ 117 YEAR_WIDE_MONTH_ABBR_WEEKDAY_DAY, 118 119 /* Displays year, month (short), day of the week (wide), and day. */ 120 YEAR_SHORT_MONTH_WIDE_WEEKDAY_DAY, 121 122 /* Displays year, month (short), day of the week (abbreviated), and day. */ 123 YEAR_SHORT_MONTH_ABBR_WEEKDAY_DAY, 124 125 /* Displays year, month (abbreviated), day of the week (wide), and day. */ 126 YEAR_ABBR_MONTH_WIDE_WEEKDAY_DAY, 127 128 /* Displays year, month (wide), and day. */ 129 YEAR_WIDE_MONTH_DAY, 130 131 /* Display week day */ 132 WEEK_DAY, 133 134 /* Display numeric month-day, and week day */ 135 NUMBER_MONTH_ABBR_WEEK_DAY, 136 137 /* Display numeric month-day */ 138 NUMBER_MONTH_DAY 139 }; 140 141 enum ElapsedPatternType { 142 /* Minute:Second */ 143 ELAPSED_MINUTE_SECOND, 144 145 /* Minute:Second:Millisecond */ 146 ELAPSED_MINUTE_SECOND_MILLISECOND, 147 148 /* HOUR:MINUTE:SECOND */ 149 ELAPSED_HOUR_MINUTE_SECOND, 150 151 /* HOUR:MINUTE */ 152 ELAPSED_HOUR_MINUTE 153 }; 154 155 enum DateTimeDataType { 156 /* Abbreviated (format style) */ 157 FORMAT_ABBR, 158 159 /* Wide (format style) */ 160 FORMAT_WIDE, 161 162 /* Abbreviated (stand-alone style) */ 163 STANDALONE_ABBR, 164 165 /* Wide (stand-alone style) */ 166 STANDALONE_WIDE 167 }; 168 169 /** 170 * @brief Enumerates plural rule types. 171 * 172 * @since 2.2 173 * @version 1.0 174 */ 175 enum PluralRuleType { 176 /* Zero */ 177 ZERO, 178 /* One */ 179 ONE, 180 /* Two */ 181 TWO, 182 /* Few */ 183 FEW, 184 /* Many */ 185 MANY, 186 /* Other */ 187 OTHER 188 }; 189 190 /** 191 * @brief Measure Format types. 192 * 193 * @since 2.2 194 * @version 1.0 195 */ 196 enum MeasureFormatType { 197 /* Short */ 198 MEASURE_SHORT = 0, 199 /* Medium */ 200 MEASURE_MEDIUM, 201 /* Long */ 202 MEASURE_LONG, 203 /* Full */ 204 MEASURE_FULL, 205 }; 206 } // namespace I18N 207 } // namespace OHOS 208 /** @} */ 209 #endif 210