| 1 | import { u8, u16, i32, u32 } from "./diplomat-runtime" |
| 2 | import { FFIError } from "./diplomat-runtime" |
| 3 | import { ICU4XCalendar } from "./ICU4XCalendar"; |
| 4 | import { ICU4XDate } from "./ICU4XDate"; |
| 5 | import { ICU4XError } from "./ICU4XError"; |
| 6 | import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; |
| 7 | import { ICU4XIsoWeekday } from "./ICU4XIsoWeekday"; |
| 8 | import { ICU4XTime } from "./ICU4XTime"; |
| 9 | import { ICU4XWeekCalculator } from "./ICU4XWeekCalculator"; |
| 10 | import { ICU4XWeekOf } from "./ICU4XWeekOf"; |
| 11 | |
| 12 | /** |
| 13 | |
| 14 | * An ICU4X DateTime object capable of containing a date and time for any calendar. |
| 15 | |
| 16 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html Rust documentation for `DateTime`} for more information. |
| 17 | */ |
| 18 | export class ICU4XDateTime { |
| 19 | |
| 20 | /** |
| 21 | |
| 22 | * Creates a new {@link ICU4XDateTime `ICU4XDateTime`} representing the ISO date and time given but in a given calendar |
| 23 | |
| 24 | * See the {@link https://docs.rs/icu/latest/icu/struct.DateTime.html#method.new_from_iso Rust documentation for `new_from_iso`} for more information. |
| 25 | * @throws {@link FFIError}<{@link ICU4XError}> |
| 26 | */ |
| 27 | static create_from_iso_in_calendar(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, nanosecond: u32, calendar: ICU4XCalendar): ICU4XDateTime | never; |
| 28 | |
| 29 | /** |
| 30 | |
| 31 | * Creates a new {@link ICU4XDateTime `ICU4XDateTime`} from the given codes, which are interpreted in the given calendar system |
| 32 | |
| 33 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.try_new_from_codes Rust documentation for `try_new_from_codes`} for more information. |
| 34 | * @throws {@link FFIError}<{@link ICU4XError}> |
| 35 | */ |
| 36 | static create_from_codes_in_calendar(era_code: string, year: i32, month_code: string, day: u8, hour: u8, minute: u8, second: u8, nanosecond: u32, calendar: ICU4XCalendar): ICU4XDateTime | never; |
| 37 | |
| 38 | /** |
| 39 | |
| 40 | * Creates a new {@link ICU4XDateTime `ICU4XDateTime`} from an {@link ICU4XDate `ICU4XDate`} and {@link ICU4XTime `ICU4XTime`} object |
| 41 | |
| 42 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.new Rust documentation for `new`} for more information. |
| 43 | */ |
| 44 | static create_from_date_and_time(date: ICU4XDate, time: ICU4XTime): ICU4XDateTime; |
| 45 | |
| 46 | /** |
| 47 | |
| 48 | * Gets a copy of the date contained in this object |
| 49 | |
| 50 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.date Rust documentation for `date`} for more information. |
| 51 | */ |
| 52 | date(): ICU4XDate; |
| 53 | |
| 54 | /** |
| 55 | |
| 56 | * Gets the time contained in this object |
| 57 | |
| 58 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.time Rust documentation for `time`} for more information. |
| 59 | */ |
| 60 | time(): ICU4XTime; |
| 61 | |
| 62 | /** |
| 63 | |
| 64 | * Converts this date to ISO |
| 65 | |
| 66 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_iso Rust documentation for `to_iso`} for more information. |
| 67 | */ |
| 68 | to_iso(): ICU4XIsoDateTime; |
| 69 | |
| 70 | /** |
| 71 | |
| 72 | * Convert this datetime to one in a different calendar |
| 73 | |
| 74 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_calendar Rust documentation for `to_calendar`} for more information. |
| 75 | */ |
| 76 | to_calendar(calendar: ICU4XCalendar): ICU4XDateTime; |
| 77 | |
| 78 | /** |
| 79 | |
| 80 | * Returns the hour in this time |
| 81 | |
| 82 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.hour Rust documentation for `hour`} for more information. |
| 83 | */ |
| 84 | hour(): u8; |
| 85 | |
| 86 | /** |
| 87 | |
| 88 | * Returns the minute in this time |
| 89 | |
| 90 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.minute Rust documentation for `minute`} for more information. |
| 91 | */ |
| 92 | minute(): u8; |
| 93 | |
| 94 | /** |
| 95 | |
| 96 | * Returns the second in this time |
| 97 | |
| 98 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.second Rust documentation for `second`} for more information. |
| 99 | */ |
| 100 | second(): u8; |
| 101 | |
| 102 | /** |
| 103 | |
| 104 | * Returns the nanosecond in this time |
| 105 | |
| 106 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.nanosecond Rust documentation for `nanosecond`} for more information. |
| 107 | */ |
| 108 | nanosecond(): u32; |
| 109 | |
| 110 | /** |
| 111 | |
| 112 | * Returns the 1-indexed day in the year for this date |
| 113 | |
| 114 | * 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. |
| 115 | */ |
| 116 | day_of_year(): u16; |
| 117 | |
| 118 | /** |
| 119 | |
| 120 | * Returns the 1-indexed day in the month for this date |
| 121 | |
| 122 | * 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. |
| 123 | */ |
| 124 | day_of_month(): u32; |
| 125 | |
| 126 | /** |
| 127 | |
| 128 | * Returns the day in the week for this day |
| 129 | |
| 130 | * 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. |
| 131 | */ |
| 132 | day_of_week(): ICU4XIsoWeekday; |
| 133 | |
| 134 | /** |
| 135 | |
| 136 | * Returns the week number in this month, 1-indexed, based on what is considered the first day of the week (often a locale preference). |
| 137 | |
| 138 | * `first_weekday` can be obtained via `first_weekday()` on {@link ICU4XWeekCalculator `ICU4XWeekCalculator`} |
| 139 | |
| 140 | * 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. |
| 141 | */ |
| 142 | week_of_month(first_weekday: ICU4XIsoWeekday): u32; |
| 143 | |
| 144 | /** |
| 145 | |
| 146 | * Returns the week number in this year, using week data |
| 147 | |
| 148 | * 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. |
| 149 | * @throws {@link FFIError}<{@link ICU4XError}> |
| 150 | */ |
| 151 | week_of_year(calculator: ICU4XWeekCalculator): ICU4XWeekOf | never; |
| 152 | |
| 153 | /** |
| 154 | |
| 155 | * Returns 1-indexed number of the month of this date in its year |
| 156 | |
| 157 | * 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. |
| 158 | |
| 159 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. |
| 160 | */ |
| 161 | ordinal_month(): u32; |
| 162 | |
| 163 | /** |
| 164 | |
| 165 | * Returns the month code for this date. Typically something like "M01", "M02", but can be more complicated for lunar calendars. |
| 166 | |
| 167 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. |
| 168 | * @throws {@link FFIError}<{@link ICU4XError}> |
| 169 | */ |
| 170 | month_code(): string | never; |
| 171 | |
| 172 | /** |
| 173 | |
| 174 | * Returns the year number in the current era for this date |
| 175 | |
| 176 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year Rust documentation for `year`} for more information. |
| 177 | */ |
| 178 | year_in_era(): i32; |
| 179 | |
| 180 | /** |
| 181 | |
| 182 | * Returns the era for this date, |
| 183 | |
| 184 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year Rust documentation for `year`} for more information. |
| 185 | * @throws {@link FFIError}<{@link ICU4XError}> |
| 186 | */ |
| 187 | era(): string | never; |
| 188 | |
| 189 | /** |
| 190 | |
| 191 | * Returns the number of months in the year represented by this date |
| 192 | |
| 193 | * 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. |
| 194 | */ |
| 195 | months_in_year(): u8; |
| 196 | |
| 197 | /** |
| 198 | |
| 199 | * Returns the number of days in the month represented by this date |
| 200 | |
| 201 | * 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. |
| 202 | */ |
| 203 | days_in_month(): u8; |
| 204 | |
| 205 | /** |
| 206 | |
| 207 | * Returns the number of days in the year represented by this date |
| 208 | |
| 209 | * 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. |
| 210 | */ |
| 211 | days_in_year(): u16; |
| 212 | |
| 213 | /** |
| 214 | |
| 215 | * Returns the {@link ICU4XCalendar `ICU4XCalendar`} object backing this date |
| 216 | |
| 217 | * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.calendar Rust documentation for `calendar`} for more information. |
| 218 | */ |
| 219 | calendar(): ICU4XCalendar; |
| 220 | } |