| 1 |
import { u8, u16, i32, u32 } from "./diplomat-runtime" |
| 2 |
import { FFIError } from "./diplomat-runtime" |
| 3 |
import { ICU4XCalendar } from "./ICU4XCalendar"; |
| 4 |
import { ICU4XError } from "./ICU4XError"; |
| 5 |
import { ICU4XIsoDate } from "./ICU4XIsoDate"; |
| 6 |
import { ICU4XIsoWeekday } from "./ICU4XIsoWeekday"; |
| 7 |
import { ICU4XWeekCalculator } from "./ICU4XWeekCalculator"; |
| 8 |
import { ICU4XWeekOf } from "./ICU4XWeekOf"; |
| 9 |
|
| 10 |
/** |
| 11 |
|
| 12 |
* An ICU4X Date object capable of containing a date and time for any calendar. |
| 13 |
|
| 14 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html Rust documentation for `Date`} for more information. |
| 15 |
*/ |
| 16 |
export class ICU4XDate { |
| 17 |
|
| 18 |
/** |
| 19 |
|
| 20 |
* Creates a new {@link ICU4XDate `ICU4XDate`} representing the ISO date and time given but in a given calendar |
| 21 |
|
| 22 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.new_from_iso Rust documentation for `new_from_iso`} for more information. |
| 23 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 24 |
*/ |
| 25 |
static create_from_iso_in_calendar(year: i32, month: u8, day: u8, calendar: ICU4XCalendar): ICU4XDate | never; |
| 26 |
|
| 27 |
/** |
| 28 |
|
| 29 |
* Creates a new {@link ICU4XDate `ICU4XDate`} from the given codes, which are interpreted in the given calendar system |
| 30 |
|
| 31 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.try_new_from_codes Rust documentation for `try_new_from_codes`} for more information. |
| 32 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 33 |
*/ |
| 34 |
static create_from_codes_in_calendar(era_code: string, year: i32, month_code: string, day: u8, calendar: ICU4XCalendar): ICU4XDate | never; |
| 35 |
|
| 36 |
/** |
| 37 |
|
| 38 |
* Convert this date to one in a different calendar |
| 39 |
|
| 40 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_calendar Rust documentation for `to_calendar`} for more information. |
| 41 |
*/ |
| 42 |
to_calendar(calendar: ICU4XCalendar): ICU4XDate; |
| 43 |
|
| 44 |
/** |
| 45 |
|
| 46 |
* Converts this date to ISO |
| 47 |
|
| 48 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_iso Rust documentation for `to_iso`} for more information. |
| 49 |
*/ |
| 50 |
to_iso(): ICU4XIsoDate; |
| 51 |
|
| 52 |
/** |
| 53 |
|
| 54 |
* Returns the 1-indexed day in the year for this date |
| 55 |
|
| 56 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_year_info Rust documentation for `day_of_year_info`} for more information. |
| 57 |
*/ |
| 58 |
day_of_year(): u16; |
| 59 |
|
| 60 |
/** |
| 61 |
|
| 62 |
* Returns the 1-indexed day in the month for this date |
| 63 |
|
| 64 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_month Rust documentation for `day_of_month`} for more information. |
| 65 |
*/ |
| 66 |
day_of_month(): u32; |
| 67 |
|
| 68 |
/** |
| 69 |
|
| 70 |
* Returns the day in the week for this day |
| 71 |
|
| 72 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week Rust documentation for `day_of_week`} for more information. |
| 73 |
*/ |
| 74 |
day_of_week(): ICU4XIsoWeekday; |
| 75 |
|
| 76 |
/** |
| 77 |
|
| 78 |
* Returns the week number in this month, 1-indexed, based on what is considered the first day of the week (often a locale preference). |
| 79 |
|
| 80 |
* `first_weekday` can be obtained via `first_weekday()` on {@link ICU4XWeekCalculator `ICU4XWeekCalculator`} |
| 81 |
|
| 82 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_month Rust documentation for `week_of_month`} for more information. |
| 83 |
*/ |
| 84 |
week_of_month(first_weekday: ICU4XIsoWeekday): u32; |
| 85 |
|
| 86 |
/** |
| 87 |
|
| 88 |
* Returns the week number in this year, using week data |
| 89 |
|
| 90 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year Rust documentation for `week_of_year`} for more information. |
| 91 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 92 |
*/ |
| 93 |
week_of_year(calculator: ICU4XWeekCalculator): ICU4XWeekOf | never; |
| 94 |
|
| 95 |
/** |
| 96 |
|
| 97 |
* Returns 1-indexed number of the month of this date in its year |
| 98 |
|
| 99 |
* Note that for lunar calendars this may not lead to the same month having the same ordinal month across years; use month_code if you care about month identity. |
| 100 |
|
| 101 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. |
| 102 |
*/ |
| 103 |
ordinal_month(): u32; |
| 104 |
|
| 105 |
/** |
| 106 |
|
| 107 |
* Returns the month code for this date. Typically something like "M01", "M02", but can be more complicated for lunar calendars. |
| 108 |
|
| 109 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. |
| 110 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 111 |
*/ |
| 112 |
month_code(): string | never; |
| 113 |
|
| 114 |
/** |
| 115 |
|
| 116 |
* Returns the year number in the current era for this date |
| 117 |
|
| 118 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year Rust documentation for `year`} for more information. |
| 119 |
*/ |
| 120 |
year_in_era(): i32; |
| 121 |
|
| 122 |
/** |
| 123 |
|
| 124 |
* Returns the era for this date, |
| 125 |
|
| 126 |
* See the {@link https://docs.rs/icu/latest/icu/struct.Date.html#method.year Rust documentation for `year`} for more information. |
| 127 |
|
| 128 |
* Additional information: {@link https://docs.rs/icu/latest/icu/types/struct.Era.html 1} |
| 129 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 130 |
*/ |
| 131 |
era(): string | never; |
| 132 |
|
| 133 |
/** |
| 134 |
|
| 135 |
* Returns the number of months in the year represented by this date |
| 136 |
|
| 137 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year Rust documentation for `months_in_year`} for more information. |
| 138 |
*/ |
| 139 |
months_in_year(): u8; |
| 140 |
|
| 141 |
/** |
| 142 |
|
| 143 |
* Returns the number of days in the month represented by this date |
| 144 |
|
| 145 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month Rust documentation for `days_in_month`} for more information. |
| 146 |
*/ |
| 147 |
days_in_month(): u8; |
| 148 |
|
| 149 |
/** |
| 150 |
|
| 151 |
* Returns the number of days in the year represented by this date |
| 152 |
|
| 153 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year Rust documentation for `days_in_year`} for more information. |
| 154 |
*/ |
| 155 |
days_in_year(): u16; |
| 156 |
|
| 157 |
/** |
| 158 |
|
| 159 |
* Returns the {@link ICU4XCalendar `ICU4XCalendar`} object backing this date |
| 160 |
|
| 161 |
* See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.calendar Rust documentation for `calendar`} for more information. |
| 162 |
*/ |
| 163 |
calendar(): ICU4XCalendar; |
| 164 |
} |