• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 INTL_ADDON_H
17 #define INTL_ADDON_H
18 
19 #include "ani.h"
20 #include "collator.h"
21 #include "date_time_format.h"
22 
23 namespace OHOS {
24 namespace Global {
25 namespace I18n {
26 class IntlAddon {
27 public:
28     static ani_string DateTimeFormat_Format(ani_env *env, ani_object object, ani_object date);
29     static ani_string DateTimeFormat_FormatRange(ani_env *env, ani_object object,
30         ani_object startDate, ani_object endDate);
31     static ani_object DateTimeFormat_ResolvedOptions(ani_env *env, ani_object object);
32     static ani_double Collator_Compare(ani_env *env, ani_object object, ani_string first, ani_string second);
33     static ani_object Collator_ResolvedOptions(ani_env *env, ani_object object);
34 
35     static ani_object DateTimeFormat_Create(ani_env *env, [[maybe_unused]] ani_object object);
36     static ani_object DateTimeFormat_CreateWithParam(ani_env *env, [[maybe_unused]] ani_object object,
37         ani_object locale, ani_object options);
38     static ani_object Collator_Create(ani_env *env, [[maybe_unused]] ani_object object);
39     static ani_object Collator_CreateWithParam(ani_env *env, [[maybe_unused]] ani_object object,
40         ani_object locale, ani_object options);
41 
42     static ani_status BindContext_DateTimeFormat(ani_env *env);
43     static ani_status BindContext_Collator(ani_env *env);
44 
45 private:
46     std::unique_ptr<Collator> collator_ = nullptr;
47     std::unique_ptr<DateTimeFormat> datefmt_ = nullptr;
48 };
49 } // namespace I18n
50 } // namespace Global
51 } // namespace OHOS
52 #endif
53