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 DATE_TIME_DATA_H 17 #define DATE_TIME_DATA_H 18 19 #include <string> 20 #include "i18n_memory_adapter.h" 21 #include "locale_info.h" 22 #include "securec.h" 23 #include "str_util.h" 24 #include "types.h" 25 26 #define MONTH_SIZE 12 27 #define DAY_SIZE 7 28 #define AM_SIZE 2 29 #define SEP_HOUR_SIZE 2 30 31 namespace OHOS { 32 namespace I18N { 33 class DateTimeData { 34 public: 35 DateTimeData(const char *amPmMarkers, const char *configs, const int size); 36 ~DateTimeData(); 37 std::string GetMonthName(int32_t index, DateTimeDataType type = DateTimeDataType::FORMAT_ABBR); 38 std::string GetDayName(int32_t index, DateTimeDataType type = DateTimeDataType::FORMAT_ABBR); 39 std::string GetAmPmMarker(int32_t index, DateTimeDataType type); 40 char *timePatterns = nullptr; 41 char *datePatterns = nullptr; 42 char *hourMinuteSecondPatterns = nullptr; 43 char *fullMediumShortPatterns = nullptr; 44 char *elapsedPatterns = nullptr; 45 char GetTimeSeparator(void) const; 46 char GetDefaultHour(void) const; 47 void SetMonthNamesData(const char *formatAbbreviatedMonthNames, const char *formatWideMonthNames, 48 const char *standaloneAbbreviatedMonthNames, const char *standaloneWideMonthNames); 49 void SetDayNamesData(const char *formatAbbreviatedDayNames, const char *formatWideDayNames, 50 const char *standaloneAbbreviatedDayNames, const char *standaloneWideDayNames); 51 void SetPatternsData(const char *datePatterns, const char *timePatterns, const char *hourMinuteSecondPatterns, 52 const char *fullMediumShortPatterns, const char *elapsedPatterns); 53 private: 54 char *formatAbbreviatedMonthNames = nullptr; 55 char *formatWideMonthNames = nullptr; 56 char *standaloneAbbreviatedMonthNames = nullptr; 57 char *standaloneWideMonthNames = nullptr; 58 char *formatAbbreviatedDayNames = nullptr; 59 char *formatWideDayNames = nullptr; 60 char *standaloneAbbreviatedDayNames = nullptr; 61 char *standaloneWideDayNames = nullptr; 62 char *amPmMarkers = nullptr; 63 char timeSeparator = ':'; 64 char defaultHour = 'H'; 65 const int CONFIG_MIN_SIZE = 2; 66 }; 67 } // namespace I18N 68 } // namespace OHOS 69 #endif 70