• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #include "i18n_calendar_impl.h"
17 #include "i18n_calendar.h"
18 #include "i18n_hilog.h"
19 
20 namespace OHOS {
21 namespace Global {
22 namespace I18n {
CCalendar(std::string localeTag,CalendarType type)23 CCalendar::CCalendar(std::string localeTag, CalendarType type)
24 {
25     calendar_ = std::make_unique<I18nCalendar>(localeTag, type);
26     if (calendar_ == nullptr) {
27         HILOG_ERROR_I18N("Create I18nCalendar fail");
28     }
29 }
30 
SetTime(double time)31 void CCalendar::SetTime(double time)
32 {
33     calendar_->SetTime(time);
34 }
35 
Set(UCalendarDateFields field,int32_t value)36 void CCalendar::Set(UCalendarDateFields field, int32_t value)
37 {
38     calendar_->Set(field, value);
39 }
40 
Set(int32_t year,int32_t month,int32_t date)41 void CCalendar::Set(int32_t year, int32_t month, int32_t date)
42 {
43     calendar_->Set(year, month, date);
44 }
45 
GetTimeZone(void)46 std::string CCalendar::GetTimeZone(void)
47 {
48     return calendar_->GetTimeZone();
49 }
50 
SetTimeZone(std::string timezoneId)51 void CCalendar::SetTimeZone(std::string timezoneId)
52 {
53     calendar_->SetTimeZone(timezoneId);
54 }
55 
Get(UCalendarDateFields field) const56 int32_t CCalendar::Get(UCalendarDateFields field) const
57 {
58     return calendar_->Get(field);
59 }
60 
Add(UCalendarDateFields field,int32_t amount)61 void CCalendar::Add(UCalendarDateFields field, int32_t amount)
62 {
63     return calendar_->Add(field, amount);
64 }
65 
SetMinimalDaysInFirstWeek(int32_t value)66 void CCalendar::SetMinimalDaysInFirstWeek(int32_t value)
67 {
68     calendar_->SetMinimalDaysInFirstWeek(value);
69 }
70 
SetFirstDayOfWeek(int32_t value)71 void CCalendar::SetFirstDayOfWeek(int32_t value)
72 {
73     calendar_->SetFirstDayOfWeek(value);
74 }
75 
GetTimeInMillis(void)76 UDate CCalendar::GetTimeInMillis(void)
77 {
78     return calendar_->GetTimeInMillis();
79 }
80 
CompareDays(UDate date)81 int32_t CCalendar::CompareDays(UDate date)
82 {
83     return calendar_->CompareDays(date);
84 }
85 
IsWeekend(void)86 bool CCalendar::IsWeekend(void)
87 {
88     return calendar_->IsWeekend();
89 }
90 
IsWeekend(int64_t date,UErrorCode & status)91 bool CCalendar::IsWeekend(int64_t date, UErrorCode &status)
92 {
93     return calendar_->IsWeekend(date, status);
94 }
95 
GetDisplayName(std::string & displayLocaleTag)96 std::string CCalendar::GetDisplayName(std::string &displayLocaleTag)
97 {
98     return calendar_->GetDisplayName(displayLocaleTag);
99 }
100 
GetMinimalDaysInFirstWeek(void)101 int32_t CCalendar::GetMinimalDaysInFirstWeek(void)
102 {
103     return calendar_->GetMinimalDaysInFirstWeek();
104 }
105 
GetFirstDayOfWeek(void)106 int32_t CCalendar::GetFirstDayOfWeek(void)
107 {
108     return calendar_->GetFirstDayOfWeek();
109 }
110 
111 }  // namespace I18n
112 }  // namespace Global
113 }  // namespace OHOS
114