diff --git a/api/@ohos.intl.d.ts b/api/@ohos.intl.d.ts index 0cbfb8e4cc7db463464282d8fdee70b5a1ecbb83..6750dc884eb95c1b9d54db8f13ade931aad3b8b8 100644 --- a/api/@ohos.intl.d.ts +++ b/api/@ohos.intl.d.ts @@ -994,10 +994,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions - * @arkts 1.1&1.2 */ export interface DateTimeOptions { /** @@ -1039,9 +1038,8 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 - * @arkts 1.1&1.2 */ locale?: string; @@ -1084,10 +1082,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.dateStyle - * @arkts 1.1&1.2 */ dateStyle?: string; @@ -1130,10 +1127,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.timeStyle - * @arkts 1.1&1.2 */ timeStyle?: string; @@ -1176,10 +1172,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.hourCycle - * @arkts 1.1&1.2 */ hourCycle?: string; @@ -1222,10 +1217,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.timeZone - * @arkts 1.1&1.2 */ timeZone?: string; @@ -1273,10 +1267,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.numberingSystem - * @arkts 1.1&1.2 */ numberingSystem?: string; @@ -1321,10 +1314,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.hour12 - * @arkts 1.1&1.2 */ hour12?: boolean; @@ -1367,10 +1359,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.weekday - * @arkts 1.1&1.2 */ weekday?: string; @@ -1413,10 +1404,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.era - * @arkts 1.1&1.2 */ era?: string; @@ -1459,10 +1449,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.year - * @arkts 1.1&1.2 */ year?: string; @@ -1505,10 +1494,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.month - * @arkts 1.1&1.2 */ month?: string; @@ -1551,10 +1539,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.day - * @arkts 1.1&1.2 */ day?: string; @@ -1597,10 +1584,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.hour - * @arkts 1.1&1.2 */ hour?: string; @@ -1643,10 +1629,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.minute - * @arkts 1.1&1.2 */ minute?: string; @@ -1689,10 +1674,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.second - * @arkts 1.1&1.2 */ second?: string; @@ -1735,10 +1719,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.timeZoneName - * @arkts 1.1&1.2 */ timeZoneName?: string; @@ -1781,10 +1764,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.dayPeriod - * @arkts 1.1&1.2 */ dayPeriod?: string; @@ -1829,10 +1811,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.localeMatcher - * @arkts 1.1&1.2 */ localeMatcher?: string; @@ -1877,10 +1858,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormatOptions.formatMatcher - * @arkts 1.1&1.2 */ formatMatcher?: string; } @@ -1913,10 +1893,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormat - * @arkts 1.1&1.2 */ export class DateTimeFormat { /** @@ -1947,10 +1926,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormat.constructor - * @arkts 1.1&1.2 */ constructor(); @@ -1995,10 +1973,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormat.constructor - * @arkts 1.1&1.2 */ constructor(locale: string | Array, options?: DateTimeOptions); @@ -2038,10 +2015,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormat.format - * @arkts 1.1&1.2 */ format(date: Date): string; @@ -2086,10 +2062,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormat.formatRange - * @arkts 1.1&1.2 */ formatRange(startDate: Date, endDate: Date): string; @@ -2125,10 +2100,9 @@ declare namespace intl { * @crossplatform * @form * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} + * @since 12 * @deprecated since 20 * @useinstead Intl.DateTimeFormat.resolvedOptions - * @arkts 1.1&1.2 */ resolvedOptions(): DateTimeOptions; } diff --git a/api/@ohos.intl.static.d.ets b/api/@ohos.intl.static.d.ets new file mode 100644 index 0000000000000000000000000000000000000000..21dc7ab49993fda803ccd2cea1152107ea3528a2 --- /dev/null +++ b/api/@ohos.intl.static.d.ets @@ -0,0 +1,308 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @kit LocalizationKit + */ + +/** + * Provides internationalization related APIs. + * + * @namespace intl + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ +declare namespace intl { + /** + * Defines the options for a DateTimeOptions object. Since API version 9, the DateTimeOptions attribute is changed + * from mandatory to optional. + * + * @interface DateTimeOptions + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + export interface DateTimeOptions { + /** + * Valid locale ID, for example, "zh-Hans-CN". The default value is the current system locale. + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + locale?: string; + + /** + * Date display format. The value can be: "long", "short", "medium", "full", or "auto". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + dateStyle?: string; + + /** + * Time display format. The value can be: "long", "short", "medium", "full", or "auto". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + timeStyle?: string; + + /** + * Hour cycle. The value can be: "h11", "h12", "h23", or "h24". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + hourCycle?: string; + + /** + * Time zone in use. The value is a valid IANA time zone ID. + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + timeZone?: string; + + /** + * Numbering system. The value can be: "adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", + * "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", + * "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", + * "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", + * "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", + * "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", or "wcho". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + numberingSystem?: string; + + /** + * Whether to use the 12-hour clock. The value true means to use the 12-hour clock, and the value false means the + * opposite. If both hour12 and hourCycle are set, hourCycle does not take effect. If hour12 and hourCycle are not + * set and the 24-hour clock is turned on, the default value of hour12 is false. + * + * @type { ?boolean } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + hour12?: boolean; + + /** + * Week display format. The value can be: "long", "short", "narrow", or "auto". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + weekday?: string; + + /** + * Epoch display format. The value can be: "long", "short", "narrow", or "auto". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + era?: string; + + /** + * Year display format. The value can be: "numeric" or "2-digit". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + year?: string; + + /** + * Month display format. The value can be: "numeric", "2-digit", "long", "short", "narrow", or "auto". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + month?: string; + + /** + * Day display format. The value can be: "numeric" or "2-digit". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + day?: string; + + /** + * Hour display format. The value can be: "numeric" or "2-digit". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + hour?: string; + + /** + * Minute display format. The value can be: "numeric" or "2-digit". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + minute?: string; + + /** + * Second display format. The value can be: "numeric" or "2-digit". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + second?: string; + + /** + * Localized representation of a time zone name. The value can be: "long", "short", or "auto". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + timeZoneName?: string; + + /** + * Time period display format. The value can be: "long", "short", "narrow", or "auto". + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + dayPeriod?: string; + + /** + * Locale matching algorithm. The value can be: + * "lookup": exact match. + * "best fit": best match. + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + localeMatcher?: string; + + /** + * Format matching algorithm. The value can be: + * "basic": exact match. + * "best fit": best match. + * + * @type { ?string } + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + formatMatcher?: string; + } + + /** + * Provides the API for formatting date strings. + * + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + export class DateTimeFormat { + /** + * Creates a DateTimeOptions object for the specified locale. + * + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + constructor(); + + /** + * Creates a DateTimeOptions object for the specified locale. + * + * @param { string | Array } locale - Locale ID or locale ID array. If the input is a locale ID array, the + * first valid locale ID is used. + * @param { DateTimeOptions } [options] - Options for creating the DateTimeOptions object.
If no options are + * set, the default values of year, month, and day are numeric. + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + constructor(locale: string | Array, options?: DateTimeOptions); + + /** + * Formats the date and time. + * + * @param { Date } date - Date and time. Note: The month starts from 0. For example, 0 indicates January. + * @returns { string } A string containing the formatted date and time. + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + format(date: Date): string; + + /** + * Formats date and time ranges. + * + * @param { Date } startDate - Start date and time. Note: The month starts from 0. For example, 0 indicates + * January. + * @param { Date } endDate - End date and time. Note: The month starts from 0. For example, 0 indicates January. + * @returns { string } a date string formatted based on the specified locale. + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + formatRange(startDate: Date, endDate: Date): string; + + /** + * Obtains the options for creating a DateTimeOptions object. + * + * @returns { DateTimeOptions } Options for the DateTimeOptions object. + * @syscap SystemCapability.Global.I18n + * @since 20 + * @arkts 1.2 + */ + resolvedOptions(): DateTimeOptions; + } +} +export default intl;