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 OHOS_I18N_WEEK_INFO_H
17 #define OHOS_I18N_WEEK_INFO_H
18 
19 #include "locale_info.h"
20 
21 namespace OHOS {
22 namespace I18N {
23 class WeekInfo {
24 public:
25     /**
26     * @brief A constructor used to create a <b>Calendar</b> instance with specified locale.
27     *
28     * @param locale Indicates the specified locale.
29     * @param status Indicates the whether the <b>Calendar</b> instances is created correctly.
30     */
31     WeekInfo(const LocaleInfo &localeInfo, I18nStatus &status);
32 
33     /**
34     * @brief A destructor used to delete the <b>WeekInfo</b> object.
35     */
36     virtual ~WeekInfo() = default;
37 
38     /**
39     * @brief Get the index of the beginning day of a week.
40     *
41     * @return Returns the index of the beginning day of a week, 1 stands for Sunday and 7 stands for Saturday
42     */
43     uint8_t GetFirstDayOfWeek();
44 
45     /**
46     * @brief Get the minimal number of days in the first week of a year.
47     *
48     * @return Returns the minimal number of days in the first week of a year.
49     */
50     uint8_t GetMinimalDaysInFirstWeek();
51 
52     /**
53     * @brief Get the index of the beginning day of weekend.
54     *
55     * @return Returns the index of the beginning day of weekend, 1 stands for Sunday and 7 stands for Saturday
56     */
57     uint8_t GetFirstDayOfWeekend();
58 
59     /**
60     * @brief Get the index of the end day of weekend.
61     *
62     * @return Returns the index of the end day of weekend, 1 stands for Sunday and 7 stands for Saturday
63     */
64     uint8_t GetLastDayOfWeekend();
65 private:
66     void Init(I18nStatus &status);
67     void ProcessWeekData(const char *data, I18nStatus &status);
68     LocaleInfo locale;
69     uint8_t firstDayOfWeek;
70     uint8_t minimalDaysInFirstWeek;
71     uint8_t firstDayOfWeekend;
72     uint8_t lastDayOfWeekend;
73 };
74 } // namespace I18N
75 } // namespace OHOS
76 #endif