From 3c98823b25044be87ee3825ea45f05414140d12c Mon Sep 17 00:00:00 2001 From: the-minions-of-cplu Date: Wed, 3 Nov 2021 16:12:03 +0800 Subject: [PATCH] add calendar Signed-off-by: the-minions-of-cplu --- api/@ohos.i18n.d.ts | 120 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/api/@ohos.i18n.d.ts b/api/@ohos.i18n.d.ts index 8e9598d253..3001b54bd8 100644 --- a/api/@ohos.i18n.d.ts +++ b/api/@ohos.i18n.d.ts @@ -165,4 +165,124 @@ export class PhoneNumberFormat { */ format(number: string): string; } + +/** + * Get a Calendar instance specified by locale and type. + * + * @param locale The locale used to get calendar. + * @param type If type is not specified, get locale's default Calendar, else get the specified type of Calendar. + * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, + * japanese, persion. + * @since 8 + */ + export function getCalendar(locale: string, type?: string): Calendar; + +export class Calendar { + /** + * set the date. + * + * @param date Date object used to set the time and date. + * @since 8 + */ + setTime(date: Date); + + /** + * set the time. + * + * @param time Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. + * @since 8 + */ + setTime(time: number); + + /** + * Set the time + * + * @param year The year field of the calendar, ranges from 0 to 9999. + * @param month The month field of the calendar, ranges from 0 to 11. + * @param date The day field of the calendar, ranges from 1 to 31. + * @param hour The hour field of the calendar, ranges from 0 to 23. + * @param minute The minute field of the calendar, ranges from 0 to 59. + * @param second the second field of the calendar, ranges from 0 to 59. + * @since 8 + */ + set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number); + + /** + * Set the timezone of this calendar. + * + * @param timezone The id of a timezone. + * @since 8 + */ + setTimeZone(timezone: string); + + /** + * Get the timezone id of this calendar instance. + * + * @return Returns the timezone id of this calendar. + * @since 8 + */ + getTimeZone(): string; + + /** + * Get the start day of a week. 0 indicates Sunday, 6 indicates Saturday. + * + * @return Returns start day of a week. + * @since 8 + */ + getFirstDayOfWeek(): number; + + /** + * Set the start day of a week. 0 indicates Sunday, 6 indicates Saturday. + * + * @param value Indicates the start day of a week. 0 indicates Sunday, 6 indicates Saturday. + * @since 8 + */ + setFirstDayOfWeek(value: number); + + /** + * Get the minial days of a week, which is needed for the first day of a year. + * + * @return Returns the minimal days of a week. + * @since 8 + */ + getMinimalDaysInFirstWeek(): number; + + /** + * Set the minial days of a week, which is needed for the first week of a year. + * + * @param value The value to be set. + * @since 8 + */ + setMinimalDaysInFirstWeek(value: number); + + /** + * Get the associated value with the field. + * + * @param field Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week + * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, + * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. + * @return Return the associated value. + * @since 8 + */ + get(field: string): number; + + /** + * Get calendar's name localized for display in the given locale. + * + * @param locale Locale used to get the localized name for this calendar. + * @return Retuns the localized name of this calendar. + * @since 8 + */ + getDisplayName(locale: string): string; + + /** + * Returns true if the given date is a weekend day. If the date is not given, + * the date object of this calendar is used. + * + * @param date Date object whose attribute is desired. + * @return Retuns whether the date is a weekend day. + * @since 8 + */ + isWeekend(date?: Date): boolean; +} } \ No newline at end of file -- Gitee