Debian Codegraph @

.cargo/vendor/js-sys/src/Temporal.rs

raw
1 use super::*;
2
3 #[wasm_bindgen]
4 extern "C" {
5 #[wasm_bindgen(js_namespace = Temporal, extends = Object)]
6 #[derive(Clone, Debug)]
7 pub type Instant;
8
9 #[wasm_bindgen(static_method_of = Instant, js_namespace = Temporal)]
10 pub fn from(val: &JsValue) -> Instant;
11
12 #[wasm_bindgen(static_method_of = Instant, js_namespace = Temporal)]
13 pub fn compare(one: &Instant, two: &Instant) -> i32;
14
15 #[wasm_bindgen(method, getter, structural, js_name = epochSeconds)]
16 pub fn epoch_seconds(this: &Instant) -> u64;
17 #[wasm_bindgen(method, getter, structural, js_name = epochMilliseconds)]
18 pub fn epoch_milliseconds(this: &Instant) -> u64;
19 #[wasm_bindgen(method, getter, structural, js_name = epochMicroseconds)]
20 pub fn epoch_microseconds(this: &Instant) -> BigInt;
21 #[wasm_bindgen(method, getter, structural, js_name = epochNanoseconds)]
22 pub fn epoch_nanoseconds(this: &Instant) -> BigInt;
23
24 /// This method adds duration to Instant.
25 ///
26 /// The years, months, weeks, and days fields of duration must be zero.
27 #[wasm_bindgen(method)]
28 pub fn add(this: &Instant, duration: &Duration, options: &JsValue) -> Instant;
29
30 /// This method subtracts duration to Instant.
31 ///
32 /// The years, months, weeks, and days fields of duration must be zero.
33 #[wasm_bindgen(method)]
34 pub fn subtract(this: &Instant, duration: &Duration, options: &JsValue) -> Instant;
35
36 /// This method computes the difference between the two times represented by zonedDateTime and
37 /// other, optionally rounds it, and returns it as a Temporal.Duration object. If other is earlier
38 /// than zonedDateTime then the resulting duration will be negative. The returned Temporal.Duration, when
39 /// added to zonedDateTime with the same options, will yield other.
40 #[wasm_bindgen(method)]
41 pub fn until(this: &Instant, other: &Instant, options: &JsValue) -> Duration;
42
43 /// This method computes the difference between the two times represented by zonedDateTime and
44 /// other, optionally rounds it, and returns it as a Temporal.Duration object. If other is later
45 /// than zonedDateTime then the resulting duration will be negative. The returned Temporal.Duration, when
46 /// added to zonedDateTime with the same options, will yield other.
47 #[wasm_bindgen(method)]
48 pub fn since(this: &Instant, other: &Instant, options: &JsValue) -> Duration;
49
50 /// Returns a new Temporal.Instant object which is zonedDateTime rounded to `roundTo` (if
51 /// a string parameter is used) or `roundingIncrement` of `smallestUnit` (if an object parameter
52 /// is used).
53 #[wasm_bindgen(method)]
54 pub fn round(this: &Instant, round_to: &JsValue) -> Instant;
55
56 #[wasm_bindgen(method)]
57 pub fn equals(this: &Instant, other: &Instant) -> bool;
58
59 /// This method overrides the Object.prototype.toString() method and provides a convenient, unambiguous
60 /// string representation of date. The string can be passed to Temporal.PlainDate.from() to
61 /// create a new Temporal.PlainDate object.
62 #[wasm_bindgen(method, js_name = toString)]
63 pub fn to_string(this: &Instant) -> JsString;
64
65 /// This method overrides `Object.prototype.toLocaleString()` to provide a human-readable,
66 /// language-sensitive representation of duration.
67 ///
68 /// The locales and options arguments are the same as in the constructor to Intl.DateTimeFormat.
69 #[wasm_bindgen(method, js_name = toLocaleString)]
70 pub fn to_locale_string(this: &Instant, locales: &JsValue, options: &JsValue) -> JsString;
71
72 }
73
74 #[wasm_bindgen]
75 extern "C" {
76 #[wasm_bindgen(js_namespace = Temporal, extends = Object)]
77 #[derive(Clone, Debug)]
78 pub type PlainDateTime;
79
80 #[wasm_bindgen(static_method_of = PlainDateTime, js_namespace = Temporal)]
81 pub fn from(val: &JsValue) -> PlainDateTime;
82
83 #[wasm_bindgen(static_method_of = PlainDateTime, js_namespace = Temporal)]
84 pub fn compare(one: &PlainDateTime, two: &PlainDateTime) -> i32;
85
86 #[wasm_bindgen(method, getter, structural)]
87 pub fn year(this: &PlainDateTime) -> i32;
88 #[wasm_bindgen(method, getter, structural)]
89 pub fn month(this: &PlainDateTime) -> u32;
90 #[wasm_bindgen(method, getter, structural)]
91 pub fn week(this: &PlainDateTime) -> u32;
92 #[wasm_bindgen(method, getter, structural)]
93 pub fn day(this: &PlainDateTime) -> u32;
94 #[wasm_bindgen(method, getter, structural)]
95 pub fn hour(this: &PlainDateTime) -> u32;
96 #[wasm_bindgen(method, getter, structural)]
97 pub fn minute(this: &PlainDateTime) -> u32;
98 #[wasm_bindgen(method, getter, structural)]
99 pub fn second(this: &PlainDateTime) -> u32;
100 #[wasm_bindgen(method, getter, structural)]
101 pub fn millisecond(this: &PlainDateTime) -> u32;
102 #[wasm_bindgen(method, getter, structural)]
103 pub fn microsecond(this: &PlainDateTime) -> u32;
104 #[wasm_bindgen(method, getter, structural)]
105 pub fn nanosecond(this: &PlainDateTime) -> u32;
106
107 /// In calendars that use eras, the era and eraYear read-only properties can be used
108 /// together to resolve an era-relative year. Both properties are undefined when using
109 /// the ISO 8601 calendar. As inputs to from or with, era and eraYear can be used instead
110 /// of year. Unlike year, eraYear may decrease as time proceeds because some
111 /// eras (like the BCE era in the Gregorian calendar) count years backwards.
112 #[wasm_bindgen(method, getter, structural, js_name = eraYear)]
113 pub fn era_year(this: &PlainDateTime) -> JsValue;
114
115 /// In calendars that use eras, the era and eraYear read-only properties can be used
116 /// together to resolve an era-relative year. Both properties are undefined when using
117 /// the ISO 8601 calendar. As inputs to from or with, era and eraYear can be used instead
118 /// of year. Unlike year, eraYear may decrease as time proceeds because some
119 /// eras (like the BCE era in the Gregorian calendar) count years backwards.
120 #[wasm_bindgen(method, getter, structural)]
121 pub fn era(this: &PlainDateTime) -> JsValue;
122
123 /// The dayOfWeek read-only property gives the weekday number that the date falls
124 /// on. For the ISO 8601 calendar, the weekday number is defined as in the ISO 8601
125 /// standard: a value between 1 and 7, inclusive, with Monday being 1, and Sunday 7.
126 #[wasm_bindgen(method, getter, structural, js_name = dayOfWeek)]
127 pub fn day_of_week(this: &PlainDateTime) -> u32;
128
129 /// The dayOfYear read-only property gives the ordinal day of the year that the date
130 /// falls on. For the ISO 8601 calendar, this is a value between 1 and 365, or 366 in
131 /// a leap year.
132 #[wasm_bindgen(method, getter, structural, js_name = dayOfYear)]
133 pub fn day_of_year(this: &PlainDateTime) -> u32;
134
135 /// The weekOfYear read-only property gives the ISO week number of the date. For the
136 /// ISO 8601 calendar, this is normally a value between 1 and 52, but in a few cases it
137 /// can be 53 as well. ISO week 1 is the week containing the first Thursday of the year.
138 #[wasm_bindgen(method, getter, structural, js_name = weekOfYear)]
139 pub fn week_of_year(this: &PlainDateTime) -> u32;
140
141 /// The daysInWeek read-only property gives the number of days in the week that the
142 /// date falls in. For the ISO 8601 calendar, this is always 7, but in other calendar
143 /// systems it may differ from week to week.
144 #[wasm_bindgen(method, getter, structural, js_name = daysInWeek)]
145 pub fn days_in_week(this: &PlainDateTime) -> u32;
146
147 /// The daysInMonth read-only property gives the number of days in the month that the
148 /// date falls in. For the ISO 8601 calendar, this is 28, 29, 30, or 31, depending
149 /// on the month and whether the year is a leap year.
150 #[wasm_bindgen(method, getter, structural, js_name = daysInMonth)]
151 pub fn days_in_month(this: &PlainDateTime) -> u32;
152
153 /// The daysInYear read-only property gives the number of days in the year that the date
154 /// falls in. For the ISO 8601 calendar, this is 365 or 366, depending on whether the year
155 /// is a leap year.
156 #[wasm_bindgen(method, getter, structural, js_name = daysInYear)]
157 pub fn days_in_year(this: &PlainDateTime) -> u32;
158
159 /// The monthsInYear read-only property gives the number of months in the year that the date
160 /// falls in. For the ISO 8601 calendar, this is always 12, but in other calendar systems
161 /// it may differ from year to year.
162 #[wasm_bindgen(method, getter, structural, js_name = monthsInWeek)]
163 pub fn months_in_year(this: &PlainDateTime) -> u32;
164
165 /// The inLeapYear read-only property tells whether the year that the date falls in is a
166 /// leap year or not. Its value is true if the year is a leap year, and false if not.
167 #[wasm_bindgen(method, getter, structural, js_name = inLeapYear)]
168 pub fn in_leap_year(this: &PlainDateTime) -> bool;
169
170 /// This method creates a new Temporal.PlainDateTime which is a copy of zonedDateTime, but any
171 /// properties present on parameter override the ones already present on zonedDateTime.
172 #[wasm_bindgen(method, js_name = withPlainDate)]
173 pub fn with(this: &PlainDateTime, parameter: &JsValue, options: &JsValue) -> PlainDateTime;
174
175 /// Returns a new `Temporal.PlainDateTime` object which replaces the calendar date of zonedDateTime
176 /// with the calendar date represented by plainDate.
177 #[wasm_bindgen(method, js_name = withPlainDate)]
178 pub fn with_plain_date(this: &PlainDateTime, date: &PlainDate) -> PlainDateTime;
179
180 /// Returns a new `Temporal.PlainDateTime` object which is the date indicated by date, projected
181 /// into calendar.
182 #[wasm_bindgen(method, js_name = withCalendar)]
183 pub fn with_calendar(this: &PlainDateTime, calendar: &str) -> PlainDateTime;
184
185 /// This method adds duration to zonedDateTime.
186 #[wasm_bindgen(method)]
187 pub fn add(this: &PlainDateTime, duration: &Duration, options: &JsValue) -> PlainDateTime;
188
189 /// This method subtracts duration to zonedDateTime.
190 #[wasm_bindgen(method)]
191 pub fn subtract(this: &PlainDateTime, duration: &Duration, options: &JsValue) -> PlainDateTime;
192
193 /// This method computes the difference between the two times represented by zonedDateTime and
194 /// other, optionally rounds it, and returns it as a Temporal.Duration object. If other is earlier
195 /// than zonedDateTime then the resulting duration will be negative. The returned Temporal.Duration, when
196 /// added to zonedDateTime with the same options, will yield other.
197 #[wasm_bindgen(method)]
198 pub fn until(this: &PlainDateTime, other: &PlainDateTime, options: &JsValue) -> Duration;
199
200 /// This method computes the difference between the two times represented by zonedDateTime and
201 /// other, optionally rounds it, and returns it as a Temporal.Duration object. If other is later
202 /// than zonedDateTime then the resulting duration will be negative. The returned Temporal.Duration, when
203 /// added to zonedDateTime with the same options, will yield other.
204 #[wasm_bindgen(method)]
205 pub fn since(this: &PlainDateTime, other: &PlainDateTime, options: &JsValue) -> Duration;
206
207 /// Returns a new Temporal.PlainDateTime object which is zonedDateTime rounded to `roundTo` (if
208 /// a string parameter is used) or `roundingIncrement` of `smallestUnit` (if an object parameter
209 /// is used).
210 #[wasm_bindgen(method)]
211 pub fn round(this: &PlainDateTime, round_to: &JsValue) -> PlainDateTime;
212
213 #[wasm_bindgen(method)]
214 pub fn equals(this: &PlainDateTime, other: &PlainDateTime) -> bool;
215
216 /// Returns: a plain object with properties expressing zonedDateTime in the ISO 8601 calendar, including
217 /// all date/time fields as well as the calendar, timeZone, and offset properties.
218 ///
219 /// This is an advanced method that's mainly useful if you are implementing a custom calendar. Most
220 /// developers will not need to use it.
221 #[wasm_bindgen(method, js_name = getISOFields)]
222 pub fn get_iso_fields(this: &PlainDateTime) -> JsValue;
223 }
224
225 #[wasm_bindgen]
226 extern "C" {
227 #[wasm_bindgen(js_namespace = Temporal, extends = Object)]
228 #[derive(Clone, Debug)]
229 pub type ZonedDateTime;
230
231 #[wasm_bindgen(static_method_of = ZonedDateTime, js_namespace = Temporal)]
232 pub fn from(val: &JsValue) -> ZonedDateTime;
233
234 #[wasm_bindgen(static_method_of = ZonedDateTime, js_namespace = Temporal)]
235 pub fn compare(one: &ZonedDateTime, two: &ZonedDateTime) -> i32;
236
237 #[wasm_bindgen(method, getter, structural)]
238 pub fn year(this: &ZonedDateTime) -> i32;
239 #[wasm_bindgen(method, getter, structural)]
240 pub fn month(this: &ZonedDateTime) -> u32;
241 #[wasm_bindgen(method, getter, structural)]
242 pub fn week(this: &ZonedDateTime) -> u32;
243 #[wasm_bindgen(method, getter, structural)]
244 pub fn day(this: &ZonedDateTime) -> u32;
245 #[wasm_bindgen(method, getter, structural)]
246 pub fn hour(this: &ZonedDateTime) -> u32;
247 #[wasm_bindgen(method, getter, structural)]
248 pub fn minute(this: &ZonedDateTime) -> u32;
249 #[wasm_bindgen(method, getter, structural)]
250 pub fn second(this: &ZonedDateTime) -> u32;
251 #[wasm_bindgen(method, getter, structural)]
252 pub fn millisecond(this: &ZonedDateTime) -> u32;
253 #[wasm_bindgen(method, getter, structural)]
254 pub fn microsecond(this: &ZonedDateTime) -> u32;
255 #[wasm_bindgen(method, getter, structural)]
256 pub fn nanosecond(this: &ZonedDateTime) -> u32;
257
258 #[wasm_bindgen(method, getter, structural, js_name = epochSeconds)]
259 pub fn epoch_seconds(this: &ZonedDateTime) -> u64;
260 #[wasm_bindgen(method, getter, structural, js_name = epochMilliseconds)]
261 pub fn epoch_milliseconds(this: &ZonedDateTime) -> u64;
262 #[wasm_bindgen(method, getter, structural, js_name = epochMicroseconds)]
263 pub fn epoch_microseconds(this: &ZonedDateTime) -> BigInt;
264 #[wasm_bindgen(method, getter, structural, js_name = epochNanoseconds)]
265 pub fn epoch_nanoseconds(this: &ZonedDateTime) -> BigInt;
266
267 /// In calendars that use eras, the era and eraYear read-only properties can be used
268 /// together to resolve an era-relative year. Both properties are undefined when using
269 /// the ISO 8601 calendar. As inputs to from or with, era and eraYear can be used instead
270 /// of year. Unlike year, eraYear may decrease as time proceeds because some
271 /// eras (like the BCE era in the Gregorian calendar) count years backwards.
272 #[wasm_bindgen(method, getter, structural, js_name = eraYear)]
273 pub fn era_year(this: &ZonedDateTime) -> JsValue;
274
275 /// In calendars that use eras, the era and eraYear read-only properties can be used
276 /// together to resolve an era-relative year. Both properties are undefined when using
277 /// the ISO 8601 calendar. As inputs to from or with, era and eraYear can be used instead
278 /// of year. Unlike year, eraYear may decrease as time proceeds because some
279 /// eras (like the BCE era in the Gregorian calendar) count years backwards.
280 #[wasm_bindgen(method, getter, structural)]
281 pub fn era(this: &ZonedDateTime) -> JsValue;
282
283 /// The dayOfWeek read-only property gives the weekday number that the date falls
284 /// on. For the ISO 8601 calendar, the weekday number is defined as in the ISO 8601
285 /// standard: a value between 1 and 7, inclusive, with Monday being 1, and Sunday 7.
286 #[wasm_bindgen(method, getter, structural, js_name = dayOfWeek)]
287 pub fn day_of_week(this: &ZonedDateTime) -> u32;
288
289 /// The dayOfYear read-only property gives the ordinal day of the year that the date
290 /// falls on. For the ISO 8601 calendar, this is a value between 1 and 365, or 366 in
291 /// a leap year.
292 #[wasm_bindgen(method, getter, structural, js_name = dayOfYear)]
293 pub fn day_of_year(this: &ZonedDateTime) -> u32;
294
295 /// The weekOfYear read-only property gives the ISO week number of the date. For the
296 /// ISO 8601 calendar, this is normally a value between 1 and 52, but in a few cases it
297 /// can be 53 as well. ISO week 1 is the week containing the first Thursday of the year.
298 #[wasm_bindgen(method, getter, structural, js_name = weekOfYear)]
299 pub fn week_of_year(this: &ZonedDateTime) -> u32;
300
301 /// The daysInWeek read-only property gives the number of days in the week that the
302 /// date falls in. For the ISO 8601 calendar, this is always 7, but in other calendar
303 /// systems it may differ from week to week.
304 #[wasm_bindgen(method, getter, structural, js_name = daysInWeek)]
305 pub fn days_in_week(this: &ZonedDateTime) -> u32;
306
307 /// The daysInMonth read-only property gives the number of days in the month that the
308 /// date falls in. For the ISO 8601 calendar, this is 28, 29, 30, or 31, depending
309 /// on the month and whether the year is a leap year.
310 #[wasm_bindgen(method, getter, structural, js_name = daysInMonth)]
311 pub fn days_in_month(this: &ZonedDateTime) -> u32;
312
313 /// The daysInYear read-only property gives the number of days in the year that the date
314 /// falls in. For the ISO 8601 calendar, this is 365 or 366, depending on whether the year
315 /// is a leap year.
316 #[wasm_bindgen(method, getter, structural, js_name = daysInYear)]
317 pub fn days_in_year(this: &ZonedDateTime) -> u32;
318
319 /// The monthsInYear read-only property gives the number of months in the year that the date
320 /// falls in. For the ISO 8601 calendar, this is always 12, but in other calendar systems
321 /// it may differ from year to year.
322 #[wasm_bindgen(method, getter, structural, js_name = monthsInWeek)]
323 pub fn months_in_year(this: &ZonedDateTime) -> u32;
324
325 /// The inLeapYear read-only property tells whether the year that the date falls in is a
326 /// leap year or not. Its value is true if the year is a leap year, and false if not.
327 #[wasm_bindgen(method, getter, structural, js_name = inLeapYear)]
328 pub fn in_leap_year(this: &ZonedDateTime) -> bool;
329
330 /// The `hoursInDay` read-only property returns the number of real-world hours
331 /// between the start of the current day (usually midnight) in zonedDateTime.timeZone to
332 /// the start of the next calendar day in the same time zone. Normally days will be 24 hours
333 /// long, but on days where there are DST changes or other time zone transitions, this
334 /// property may return 23 or 25. In rare cases, other integers or even non-integer
335 /// values may be returned, e.g. when time zone definitions change by less than one hour.
336 #[wasm_bindgen(method, getter, structural, js_name = inLeapYear)]
337 pub fn hours_in_day(this: &ZonedDateTime) -> u32;
338
339 #[wasm_bindgen(method, getter, structural, js_name = startOfDay)]
340 pub fn start_of_day(this: &ZonedDateTime) -> ZonedDateTime;
341
342 /// The offset read-only property is the offset (formatted as a string) relative
343 /// to UTC of the current time zone and exact instant. Examples: '-08:00' or '+05:30'
344 #[wasm_bindgen(method, getter, structural)]
345 pub fn offset(this: &ZonedDateTime) -> JsString;
346
347 /// This method creates a new Temporal.ZonedDateTime which is a copy of zonedDateTime, but any
348 /// properties present on parameter override the ones already present on zonedDateTime.
349 #[wasm_bindgen(method, js_name = withPlainDate)]
350 pub fn with(this: &ZonedDateTime, parameter: &JsValue, options: &JsValue) -> ZonedDateTime;
351
352 /// Returns a new `Temporal.ZonedDateTime` object which replaces the calendar date of zonedDateTime
353 /// with the calendar date represented by plainDate.
354 #[wasm_bindgen(method, js_name = withPlainDate)]
355 pub fn with_plain_date(this: &ZonedDateTime, date: &PlainDate) -> ZonedDateTime;
356
357 /// Returns a new `Temporal.ZonedDateTime` object which is the date indicated by date, projected
358 /// into calendar.
359 #[wasm_bindgen(method, js_name = withCalendar)]
360 pub fn with_calendar(this: &ZonedDateTime, calendar: &str) -> ZonedDateTime;
361
362 /// This method adds duration to zonedDateTime.
363 #[wasm_bindgen(method)]
364 pub fn add(this: &ZonedDateTime, duration: &Duration, options: &JsValue) -> ZonedDateTime;
365
366 /// This method subtracts duration to zonedDateTime.
367 #[wasm_bindgen(method)]
368 pub fn subtract(this: &ZonedDateTime, duration: &Duration, options: &JsValue) -> ZonedDateTime;
369
370 /// This method computes the difference between the two times represented by zonedDateTime and
371 /// other, optionally rounds it, and returns it as a Temporal.Duration object. If other is earlier
372 /// than zonedDateTime then the resulting duration will be negative. The returned Temporal.Duration, when
373 /// added to zonedDateTime with the same options, will yield other.
374 #[wasm_bindgen(method)]
375 pub fn until(this: &ZonedDateTime, other: &ZonedDateTime, options: &JsValue) -> Duration;
376
377 /// This method computes the difference between the two times represented by zonedDateTime and
378 /// other, optionally rounds it, and returns it as a Temporal.Duration object. If other is later
379 /// than zonedDateTime then the resulting duration will be negative. The returned Temporal.Duration, when
380 /// added to zonedDateTime with the same options, will yield other.
381 #[wasm_bindgen(method)]
382 pub fn since(this: &ZonedDateTime, other: &ZonedDateTime, options: &JsValue) -> Duration;
383
384 /// Returns a new Temporal.ZonedDateTime object which is zonedDateTime rounded to `roundTo` (if
385 /// a string parameter is used) or `roundingIncrement` of `smallestUnit` (if an object parameter
386 /// is used).
387 #[wasm_bindgen(method)]
388 pub fn round(this: &ZonedDateTime, round_to: &JsValue) -> ZonedDateTime;
389
390 #[wasm_bindgen(method)]
391 pub fn equals(this: &ZonedDateTime, other: &ZonedDateTime) -> bool;
392
393 /// Returns: a plain object with properties expressing zonedDateTime in the ISO 8601 calendar, including
394 /// all date/time fields as well as the calendar, timeZone, and offset properties.
395 ///
396 /// This is an advanced method that's mainly useful if you are implementing a custom calendar. Most
397 /// developers will not need to use it.
398 #[wasm_bindgen(method, js_name = getISOFields)]
399 pub fn get_iso_fields(this: &ZonedDateTime) -> JsValue;
400 }
401
402 #[wasm_bindgen]
403 extern "C" {
404 #[wasm_bindgen(js_namespace = Temporal, extends = Object)]
405 #[derive(Clone, Debug)]
406 pub type Duration;
407
408 #[wasm_bindgen(static_method_of = Duration, js_namespace = Temporal)]
409 pub fn from(val: &JsValue) -> Duration;
410
411 #[wasm_bindgen(static_method_of = Duration, js_namespace = Temporal)]
412 pub fn compare(one: &Duration, two: &Duration) -> i32;
413
414 #[wasm_bindgen(method, getter, structural)]
415 pub fn years(this: &Duration) -> i32;
416 #[wasm_bindgen(method, getter, structural)]
417 pub fn months(this: &Duration) -> i32;
418 #[wasm_bindgen(method, getter, structural)]
419 pub fn weeks(this: &Duration) -> i32;
420 #[wasm_bindgen(method, getter, structural)]
421 pub fn days(this: &Duration) -> i32;
422 #[wasm_bindgen(method, getter, structural)]
423 pub fn hours(this: &Duration) -> i32;
424 #[wasm_bindgen(method, getter, structural)]
425 pub fn minutes(this: &Duration) -> i32;
426 #[wasm_bindgen(method, getter, structural)]
427 pub fn seconds(this: &Duration) -> i32;
428 #[wasm_bindgen(method, getter, structural)]
429 pub fn milliseconds(this: &Duration) -> i32;
430 #[wasm_bindgen(method, getter, structural)]
431 pub fn microseconds(this: &Duration) -> i32;
432 #[wasm_bindgen(method, getter, structural)]
433 pub fn nanoseconds(this: &Duration) -> i32;
434
435 /// The read-only `sign` property has the value –1, 0, or 1, depending on whether
436 /// the duration is negative, zero, or positive.
437 #[wasm_bindgen(method, getter, structural)]
438 pub fn sign(this: &Duration) -> i32;
439
440 /// The read-only `blank` property is a convenience property that tells whether duration
441 /// represents a zero length of time. In other words, `duration.blank === (duration.sign === 0)`.
442 #[wasm_bindgen(method, getter, structural)]
443 pub fn blank(this: &Duration) -> bool;
444
445 /// In order to be valid, the resulting duration must not have fields with mixed signs, and
446 /// so the result is balanced. For usage examples and a more complete explanation of how
447 /// balancing works and why it is necessary, see [Duration balancing].
448 ///
449 /// [Duration balancing]: https://tc39.es/proposal-temporal/docs/balancing.html
450 #[wasm_bindgen(method)]
451 pub fn add(this: &Duration, other: &Duration, options: &JsValue) -> Duration;
452
453 /// In order to be valid, the resulting duration must not have fields with mixed signs, and
454 /// so the result is balanced. For usage examples and a more complete explanation of how
455 /// balancing works and why it is necessary, see [Duration balancing].
456 ///
457 /// [Duration balancing]: https://tc39.es/proposal-temporal/docs/balancing.html
458 #[wasm_bindgen(method)]
459 pub fn subtract(this: &Duration, other: &Duration, options: &JsValue) -> Duration;
460
461 /// This method gives the absolute value of duration. It returns a newly constructed
462 /// `Temporal.Duration` with all the fields having the same magnitude as those of
463 /// duration, but positive. If duration is already positive or zero, then the returned
464 /// object is a copy of duration.
465 #[wasm_bindgen(method)]
466 pub fn abs(this: &Duration) -> Duration;
467
468 /// Rounds and/or balances duration to the given largest and smallest units and rounding
469 /// increment, and returns the result as a new `Temporal.Duration` object.
470 #[wasm_bindgen(method)]
471 pub fn round(this: &Duration, round_to: &JsValue) -> Duration;
472
473 /// Calculates the number of units of time that can fit in a particular `Temporal.Duration`.
474 /// If the duration IS NOT evenly divisible by the desired unit, then a fractional remainder
475 /// will be present in the result. If the duration IS evenly divisible by the desired
476 /// unit, then the integer result will be identical
477 /// to `duration.round({ smallestUnit: unit, largestUnit: unit, relativeTo })[unit]`
478 #[wasm_bindgen(method)]
479 pub fn total(this: &Duration, total_of: &JsValue) -> f64;
480
481 /// This method overrides `Object.prototype.toString()` and provides the ISO 8601
482 /// description of the duration.
483 #[wasm_bindgen(method, js_name = toString)]
484 pub fn to_string(this: &Duration, options: &JsValue) -> JsString;
485
486 /// This method is the same as duration.toString(). It is usually not called directly, but
487 /// it can be called automatically by JSON.stringify().
488 #[wasm_bindgen(method, js_name = toJson)]
489 pub fn to_json(this: &Duration) -> JsString;
490
491 /// This method overrides `Object.prototype.toLocaleString()` to provide a human-readable,
492 /// language-sensitive representation of duration.
493 ///
494 /// The locales and options arguments are the same as in the constructor to Intl.DurationFormat.
495 #[wasm_bindgen(method, js_name = toLocaleString)]
496 pub fn to_locale_string(this: &Duration, locales: &JsValue, options: &JsValue) -> JsString;
497
498 }
499
500 #[wasm_bindgen]
501 extern "C" {
502 #[wasm_bindgen(js_namespace = Temporal, extends = Object)]
503 #[derive(Clone, Debug)]
504 pub type PlainTime;
505
506 #[wasm_bindgen(static_method_of = PlainTime, js_namespace = Temporal)]
507 pub fn from(val: &JsValue) -> PlainTime;
508
509 #[wasm_bindgen(static_method_of = PlainTime, js_namespace = Temporal)]
510 pub fn compare(one: &PlainTime, two: &PlainTime) -> i32;
511
512 #[wasm_bindgen(method, getter, structural)]
513 pub fn hour(this: &PlainTime) -> u32;
514 #[wasm_bindgen(method, getter, structural)]
515 pub fn minute(this: &PlainTime) -> u32;
516 #[wasm_bindgen(method, getter, structural)]
517 pub fn second(this: &PlainTime) -> u32;
518 #[wasm_bindgen(method, getter, structural)]
519 pub fn millisecond(this: &PlainTime) -> u32;
520 #[wasm_bindgen(method, getter, structural)]
521 pub fn microsecond(this: &PlainTime) -> u32;
522 #[wasm_bindgen(method, getter, structural)]
523 pub fn nanosecond(this: &PlainTime) -> u32;
524
525 /// This method adds duration to PlainTime.
526 #[wasm_bindgen(method)]
527 pub fn add(this: &PlainTime, duration: &Duration, options: &JsValue) -> PlainTime;
528
529 /// This method subtracts duration to PlainTime.
530 #[wasm_bindgen(method)]
531 pub fn subtract(this: &PlainTime, duration: &Duration, options: &JsValue) -> PlainTime;
532
533 /// This method computes the difference between the two times represented by PlainTime and
534 /// other, optionally rounds it, and returns it as a Temporal.Duration object. If other is earlier
535 /// than zonedDateTime then the resulting duration will be negative. The returned Temporal.Duration, when
536 /// added to zonedDateTime with the same options, will yield other.
537 #[wasm_bindgen(method)]
538 pub fn until(this: &PlainTime, other: &PlainTime, options: &JsValue) -> Duration;
539
540 /// This method computes the difference between the two times represented by PlainTime and
541 /// other, optionally rounds it, and returns it as a Temporal.Duration object. If other is later
542 /// than zonedDateTime then the resulting duration will be negative. The returned Temporal.Duration, when
543 /// added to zonedDateTime with the same options, will yield other.
544 #[wasm_bindgen(method)]
545 pub fn since(this: &PlainTime, other: &PlainTime, options: &JsValue) -> Duration;
546
547 /// Returns a new Temporal.ZonedDateTime object which is PlainTime rounded to `roundTo` (if
548 /// a string parameter is used) or `roundingIncrement` of `smallestUnit` (if an object parameter
549 /// is used).
550 #[wasm_bindgen(method)]
551 pub fn round(this: &PlainTime, round_to: &JsValue) -> PlainTime;
552
553 #[wasm_bindgen(method)]
554 pub fn equals(this: &PlainTime, other: &PlainTime) -> bool;
555
556 /// This method overrides `Object.prototype.toLocaleString()` to provide a human-readable,
557 /// language-sensitive representation of duration.
558 ///
559 /// The locales and options arguments are the same as in the constructor to Intl.DateTimeFormat.
560 #[wasm_bindgen(method, js_name = toLocaleString)]
561 pub fn to_locale_string(this: &PlainTime, locales: &JsValue, options: &JsValue) -> JsString;
562
563 /// Returns: a plain object with properties expressing PlainTime in the ISO 8601 calendar, including
564 /// all date/time fields as well as the calendar, timeZone, and offset properties.
565 ///
566 /// This is an advanced method that's mainly useful if you are implementing a custom calendar. Most
567 /// developers will not need to use it.
568 #[wasm_bindgen(method, js_name = getISOFields)]
569 pub fn get_iso_fields(this: &PlainTime) -> JsValue;
570
571 }
572
573 #[wasm_bindgen]
574 extern "C" {
575 /// A Temporal.PlainYearMonth represents a particular month on the calendar. For example, it
576 /// could be used to represent a particular instance of a monthly recurring event, like "the
577 /// June 2019 meeting".
578 #[wasm_bindgen(js_namespace = Temporal, extends = Object)]
579 #[derive(Clone, Debug)]
580 pub type PlainYearMonth;
581
582 #[wasm_bindgen(static_method_of = PlainYearMonth, js_namespace = Temporal)]
583 pub fn from(val: &JsValue) -> PlainYearMonth;
584
585 #[wasm_bindgen(static_method_of = PlainYearMonth, js_namespace = Temporal)]
586 pub fn compare(one: &PlainYearMonth, two: &PlainYearMonth) -> i32;
587
588 /// `year` is a signed integer representing the number of years relative to a
589 /// calendar-specific epoch. For calendars that use eras, the anchor is usually
590 /// aligned with the latest era so that eraYear === year for all dates in that
591 /// era. However, some calendars like Japanese may use a different anchor.
592 #[wasm_bindgen(method, getter, structural)]
593 pub fn year(this: &PlainYearMonth) -> i32;
594
595 /// `month` is a positive integer representing the ordinal index of the month in
596 /// the current year. For calendars like Hebrew or Chinese that use leap
597 /// months, the same-named month may have a different month value depending on
598 /// the year. The first month in every year has month equal to 1. The last month
599 /// of every year has month equal to the monthsInYear property. month values
600 /// start at 1, which is different from legacy Date where months are represented
601 /// by zero-based indices (0 to 11).
602 #[wasm_bindgen(method, getter, structural)]
603 pub fn month(this: &PlainYearMonth) -> u32;
604
605 /// `monthCode` is a calendar-specific string that identifies the month in
606 /// a year-independent way. For common (non-leap) months, monthCode should
607 /// be `M${month}`, where month is zero padded up to two digits. For uncommon
608 /// (leap) months in lunisolar calendars like Hebrew or Chinese, the month code
609 /// is the previous month's code with with an "L" suffix appended.
610 /// Examples:
611 /// * 'M02' => February;
612 /// * 'M08L' => repeated 8th month in the Chinese calendar;
613 /// * 'M05L' => Adar I in the Hebrew calendar.
614 #[wasm_bindgen(method, getter, structural, js_name = monthCode)]
615 pub fn month_code(this: &PlainYearMonth) -> JsString;
616
617 /// In calendars that use eras, the era and eraYear read-only properties can be used
618 /// together to resolve an era-relative year. Both properties are undefined when using
619 /// the ISO 8601 calendar. As inputs to from or with, era and eraYear can be used instead
620 /// of year. Unlike year, eraYear may decrease as time proceeds because some
621 /// eras (like the BCE era in the Gregorian calendar) count years backwards.
622 #[wasm_bindgen(method, getter, structural, js_name = eraYear)]
623 pub fn era_year(this: &PlainYearMonth) -> JsValue;
624
625 /// In calendars that use eras, the era and eraYear read-only properties can be used
626 /// together to resolve an era-relative year. Both properties are undefined when using
627 /// the ISO 8601 calendar. As inputs to from or with, era and eraYear can be used instead
628 /// of year. Unlike year, eraYear may decrease as time proceeds because some
629 /// eras (like the BCE era in the Gregorian calendar) count years backwards.
630 #[wasm_bindgen(method, getter, structural)]
631 pub fn era(this: &PlainYearMonth) -> JsValue;
632
633 /// The daysInMonth read-only property gives the number of days in the month that the
634 /// date falls in. For the ISO 8601 calendar, this is 28, 29, 30, or 31, depending
635 /// on the month and whether the year is a leap year.
636 #[wasm_bindgen(method, getter, structural, js_name = daysInMonth)]
637 pub fn days_in_month(this: &PlainYearMonth) -> u32;
638
639 /// The daysInYear read-only property gives the number of days in the year that the date
640 /// falls in. For the ISO 8601 calendar, this is 365 or 366, depending on whether the year
641 /// is a leap year.
642 #[wasm_bindgen(method, getter, structural, js_name = daysInYear)]
643 pub fn days_in_year(this: &PlainYearMonth) -> u32;
644
645 /// The monthsInYear read-only property gives the number of months in the year that the date
646 /// falls in. For the ISO 8601 calendar, this is always 12, but in other calendar systems
647 /// it may differ from year to year.
648 #[wasm_bindgen(method, getter, structural, js_name = monthsInWeek)]
649 pub fn months_in_year(this: &PlainYearMonth) -> u32;
650
651 /// The inLeapYear read-only property tells whether the year that the date falls in is a
652 /// leap year or not. Its value is true if the year is a leap year, and false if not.
653 #[wasm_bindgen(method, getter, structural, js_name = inLeapYear)]
654 pub fn in_leap_year(this: &PlainYearMonth) -> bool;
655
656 /// **Parameters:**
657 ///
658 ///- `duration` (`Temporal.Duration` or value convertible to one): The duration to add.
659 ///- `options` (optional object): An object with properties representing options for the addition.
660 ///The following options are recognized:
661 ///- `overflow` (optional string): How to deal with additions that result in out-of-range values.
662 /// Allowed values are `constrain` and `reject`.
663 /// The default is `constrain`.
664 ///
665 ///**Returns:** a new `Temporal.PlainYearMonth` object which is the date indicated by `date` plus `duration`.
666 ///
667 ///This method adds `duration` to `date`, returning a date that is in the future relative to `date`.
668 ///
669 ///The `duration` argument is an object with properties denoting a duration, such as `{ days: 5 }`, or a string such as `P5D`, or a `Temporal.Duration` object.
670 ///If `duration` is not a `Temporal.Duration` object, then it will be converted to one as if it were passed to `Temporal.Duration.from()`.
671 ///
672 ///Some additions may be ambiguous, because months have different lengths.
673 ///For example, adding one month to August 31 would result in September 31, which doesn't exist.
674 ///For these cases, the `overflow` option tells what to do:
675 ///
676 ///- In `constrain` mode (the default), out-of-range values are clamped to the nearest in-range value.
677 ///- In `reject` mode, an addition that would result in an out-of-range value fails, and a `RangeError` is thrown.
678 ///
679 ///Additionally, if the result is earlier or later than the range of dates that `Temporal.PlainYearMonth` can represent (approximately half a million years centered on the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time)), then this method will throw a `RangeError` regardless of `overflow`.
680 ///
681 ///Adding a negative duration is equivalent to subtracting the absolute value of that duration.
682 #[wasm_bindgen(method)]
683 pub fn add(this: &PlainYearMonth, duration: &Duration, options: &JsValue) -> PlainYearMonth;
684
685 /// **Parameters:**
686 ///- `duration` (`Temporal.Duration` or value convertible to one): The duration to subtract.
687 ///- `options` (optional object): An object with properties representing options for the subtraction.
688 ///The following options are recognized:
689 ///- `overflow` (string): How to deal with subtractions that result in out-of-range values.
690 /// Allowed values are `constrain` and `reject`.
691 /// The default is `constrain`.
692 ///
693 ///**Returns:** a new `Temporal.PlainYearMonth` object which is the date indicated by `date` minus `duration`.
694 ///
695 ///This method subtracts `duration` from `date`, returning a date that is in the past relative to `date`.
696 ///
697 ///The `duration` argument is an object with properties denoting a duration, such as `{ days: 5 }`, or a string such as `P5D`, or a `Temporal.Duration` object.
698 ///If `duration` is not a `Temporal.Duration` object, then it will be converted to one as if it were passed to `Temporal.Duration.from()`.
699 ///
700 ///Some subtractions may be ambiguous, because months have different lengths.
701 ///For example, subtracting one month from July 31 would result in June 31, which doesn't exist.
702 ///For these cases, the `overflow` option tells what to do:
703 ///
704 ///- In `constrain` mode (the default), out-of-range values are clamped to the nearest in-range value.
705 ///- In `reject` mode, an addition that would result in an out-of-range value fails, and a `RangeError` is thrown.
706 ///
707 ///Additionally, if the result is earlier or later than the range of dates that `Temporal.PlainDate` can represent (approximately half a million years centered on the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time)), then this method will throw a `RangeError` regardless of `overflow`.
708 ///
709 ///Subtracting a negative duration is equivalent to adding the absolute value of that duration.
710 ///
711 #[wasm_bindgen(method)]
712 pub fn subtract(
713 this: &PlainYearMonth,
714 duration: &Duration,
715 options: &JsValue,
716 ) -> PlainYearMonth;
717
718 /// This function exists because it's not possible to compare using date == other
719 /// or date === other, due to ambiguity in the primitive representation and between
720 /// Temporal types.
721 ///
722 /// If you don't need to know the order in which the two dates occur, then this function
723 /// may be less typing and more efficient than Temporal.PlainDate.compare.
724 #[wasm_bindgen(method)]
725 pub fn equals(this: &PlainYearMonth, other: &PlainYearMonth) -> bool;
726
727 /// This method overrides the Object.prototype.toString() method and provides a convenient, unambiguous
728 /// string representation of date. The string can be passed to Temporal.PlainYearMonth.from() to
729 /// create a new Temporal.PlainDate object.
730 #[wasm_bindgen(method, js_name = toString)]
731 pub fn to_string(this: &PlainYearMonth) -> JsString;
732
733 /// This method overrides `Object.prototype.toLocaleString()` to provide a human-readable,
734 /// language-sensitive representation of duration.
735 ///
736 /// The locales and options arguments are the same as in the constructor to Intl.DateTimeFormat.
737 #[wasm_bindgen(method, js_name = toLocaleString)]
738 pub fn to_locale_string(
739 this: &PlainYearMonth,
740 locales: &JsValue,
741 options: &JsValue,
742 ) -> JsString;
743
744 /// Returns: a plain object with properties expressing date in the ISO 8601
745 /// calendar, as well as the value of date.calendar.
746 ///
747 /// This method is mainly useful if you are implementing a custom calendar. Most
748 /// code will not need to use it.
749 #[wasm_bindgen(method, js_name = getISOFields)]
750 pub fn get_iso_fields(this: &PlainYearMonth) -> JsValue;
751
752 }
753
754 #[wasm_bindgen]
755 extern "C" {
756 /// A date without a year component. This is useful to express
757 /// things like "Bastille Day is on the 14th of July".
758 #[wasm_bindgen(js_namespace = Temporal, extends = Object)]
759 #[derive(Clone, Debug)]
760 pub type PlainMonthDay;
761
762 #[wasm_bindgen(static_method_of = PlainMonthDay, js_namespace = Temporal)]
763 pub fn from(val: &JsValue) -> PlainMonthDay;
764
765 #[wasm_bindgen(static_method_of = PlainMonthDay, js_namespace = Temporal)]
766 pub fn compare(one: &PlainMonthDay, two: &PlainMonthDay) -> i32;
767
768 /// `monthCode` is a calendar-specific string that identifies the month in
769 /// a year-independent way. For common (non-leap) months, monthCode should
770 /// be `M${month}`, where month is zero padded up to two digits. For uncommon
771 /// (leap) months in lunisolar calendars like Hebrew or Chinese, the month code
772 /// is the previous month's code with with an "L" suffix appended.
773 /// Examples:
774 /// * 'M02' => February;
775 /// * 'M08L' => repeated 8th month in the Chinese calendar;
776 /// * 'M05L' => Adar I in the Hebrew calendar.
777 ///
778 /// Note that this type has no month property, because month is ambiguous for some
779 /// calendars without knowing the year. Instead, the monthCode property is used which
780 /// is year-independent in all calendars.
781 #[wasm_bindgen(method, getter, structural, js_name = monthCode)]
782 pub fn month_code(this: &PlainMonthDay) -> JsString;
783
784 /// day is a positive integer representing the day of the month.
785 #[wasm_bindgen(method, getter, structural)]
786 pub fn day(this: &PlainMonthDay) -> u32;
787
788 /// This function exists because it's not possible to compare using date == other
789 /// or date === other, due to ambiguity in the primitive representation and between
790 /// Temporal types.
791 ///
792 /// If you don't need to know the order in which the two dates occur, then this function
793 /// may be less typing and more efficient than Temporal.PlainMonthDay.compare.
794 ///
795 /// Note that this function will return false if the two objects have different calendar
796 /// properties, even if the actual dates are equal.
797 #[wasm_bindgen(method)]
798 pub fn equals(this: &PlainMonthDay, other: &PlainMonthDay) -> bool;
799
800 /// This method overrides the Object.prototype.toString() method and provides a convenient, unambiguous
801 /// string representation of date. The string can be passed to Temporal.PlainMonthDay.from() to
802 /// create a new Temporal.PlainMonthDay object.
803 #[wasm_bindgen(method, js_name = toString)]
804 pub fn to_string(this: &PlainMonthDay) -> JsString;
805
806 /// This method overrides `Object.prototype.toLocaleString()` to provide a human-readable,
807 /// language-sensitive representation of duration.
808 ///
809 /// The locales and options arguments are the same as in the constructor to Intl.DateTimeFormat.
810 #[wasm_bindgen(method, js_name = toLocaleString)]
811 pub fn to_locale_string(this: &PlainMonthDay, locales: &JsValue, options: &JsValue)
812 -> JsString;
813
814 /// Returns: a plain object with properties expressing date in the ISO 8601
815 /// calendar, as well as the value of date.calendar.
816 ///
817 /// This method is mainly useful if you are implementing a custom calendar. Most
818 /// code will not need to use it.
819 #[wasm_bindgen(method, js_name = getISOFields)]
820 pub fn get_iso_fields(this: &PlainMonthDay) -> JsValue;
821
822 }
823
824 #[wasm_bindgen]
825 extern "C" {
826 #[wasm_bindgen(js_namespace = Temporal, extends = Object)]
827 #[derive(Clone, Debug)]
828 pub type PlainDate;
829
830 #[wasm_bindgen(js_namespace = Temporal, constructor)]
831 pub fn new(year: i32, month: u32, day: u32) -> PlainDate;
832
833 #[wasm_bindgen(static_method_of = PlainDate, js_namespace = Temporal)]
834 pub fn from(val: &JsValue) -> PlainDate;
835
836 #[wasm_bindgen(static_method_of = PlainDate, js_namespace = Temporal)]
837 pub fn compare(one: &PlainDate, two: &PlainDate) -> i32;
838
839 /// `year` is a signed integer representing the number of years relative to a
840 /// calendar-specific epoch. For calendars that use eras, the anchor is usually
841 /// aligned with the latest era so that eraYear === year for all dates in that
842 /// era. However, some calendars like Japanese may use a different anchor.
843 #[wasm_bindgen(method, getter, structural)]
844 pub fn year(this: &PlainDate) -> i32;
845
846 /// `month` is a positive integer representing the ordinal index of the month in
847 /// the current year. For calendars like Hebrew or Chinese that use leap
848 /// months, the same-named month may have a different month value depending on
849 /// the year. The first month in every year has month equal to 1. The last month
850 /// of every year has month equal to the monthsInYear property. month values
851 /// start at 1, which is different from legacy Date where months are represented
852 /// by zero-based indices (0 to 11).
853 #[wasm_bindgen(method, getter, structural)]
854 pub fn month(this: &PlainDate) -> u32;
855
856 /// `monthCode` is a calendar-specific string that identifies the month in
857 /// a year-independent way. For common (non-leap) months, monthCode should
858 /// be `M${month}`, where month is zero padded up to two digits. For uncommon
859 /// (leap) months in lunisolar calendars like Hebrew or Chinese, the month code
860 /// is the previous month's code with with an "L" suffix appended.
861 /// Examples:
862 /// * 'M02' => February;
863 /// * 'M08L' => repeated 8th month in the Chinese calendar;
864 /// * 'M05L' => Adar I in the Hebrew calendar.
865 #[wasm_bindgen(method, getter, structural, js_name = monthCode)]
866 pub fn month_code(this: &PlainDate) -> JsString;
867
868 /// day is a positive integer representing the day of the month.
869 #[wasm_bindgen(method, getter, structural)]
870 pub fn day(this: &PlainDate) -> u32;
871
872 /// In calendars that use eras, the era and eraYear read-only properties can be used
873 /// together to resolve an era-relative year. Both properties are undefined when using
874 /// the ISO 8601 calendar. As inputs to from or with, era and eraYear can be used instead
875 /// of year. Unlike year, eraYear may decrease as time proceeds because some
876 /// eras (like the BCE era in the Gregorian calendar) count years backwards.
877 #[wasm_bindgen(method, getter, structural, js_name = eraYear)]
878 pub fn era_year(this: &PlainDate) -> JsValue;
879
880 /// In calendars that use eras, the era and eraYear read-only properties can be used
881 /// together to resolve an era-relative year. Both properties are undefined when using
882 /// the ISO 8601 calendar. As inputs to from or with, era and eraYear can be used instead
883 /// of year. Unlike year, eraYear may decrease as time proceeds because some
884 /// eras (like the BCE era in the Gregorian calendar) count years backwards.
885 #[wasm_bindgen(method, getter, structural)]
886 pub fn era(this: &PlainDate) -> JsValue;
887
888 /// The dayOfWeek read-only property gives the weekday number that the date falls
889 /// on. For the ISO 8601 calendar, the weekday number is defined as in the ISO 8601
890 /// standard: a value between 1 and 7, inclusive, with Monday being 1, and Sunday 7.
891 #[wasm_bindgen(method, getter, structural, js_name = dayOfWeek)]
892 pub fn day_of_week(this: &PlainDate) -> u32;
893
894 /// The dayOfYear read-only property gives the ordinal day of the year that the date
895 /// falls on. For the ISO 8601 calendar, this is a value between 1 and 365, or 366 in
896 /// a leap year.
897 #[wasm_bindgen(method, getter, structural, js_name = dayOfYear)]
898 pub fn day_of_year(this: &PlainDate) -> u32;
899
900 /// The weekOfYear read-only property gives the ISO week number of the date. For the
901 /// ISO 8601 calendar, this is normally a value between 1 and 52, but in a few cases it
902 /// can be 53 as well. ISO week 1 is the week containing the first Thursday of the year.
903 #[wasm_bindgen(method, getter, structural, js_name = weekOfYear)]
904 pub fn week_of_year(this: &PlainDate) -> u32;
905
906 /// The daysInWeek read-only property gives the number of days in the week that the
907 /// date falls in. For the ISO 8601 calendar, this is always 7, but in other calendar
908 /// systems it may differ from week to week.
909 #[wasm_bindgen(method, getter, structural, js_name = daysInWeek)]
910 pub fn days_in_week(this: &PlainDate) -> u32;
911
912 /// The daysInMonth read-only property gives the number of days in the month that the
913 /// date falls in. For the ISO 8601 calendar, this is 28, 29, 30, or 31, depending
914 /// on the month and whether the year is a leap year.
915 #[wasm_bindgen(method, getter, structural, js_name = daysInMonth)]
916 pub fn days_in_month(this: &PlainDate) -> u32;
917
918 /// The daysInYear read-only property gives the number of days in the year that the date
919 /// falls in. For the ISO 8601 calendar, this is 365 or 366, depending on whether the year
920 /// is a leap year.
921 #[wasm_bindgen(method, getter, structural, js_name = daysInYear)]
922 pub fn days_in_year(this: &PlainDate) -> u32;
923
924 /// The monthsInYear read-only property gives the number of months in the year that the date
925 /// falls in. For the ISO 8601 calendar, this is always 12, but in other calendar systems
926 /// it may differ from year to year.
927 #[wasm_bindgen(method, getter, structural, js_name = monthsInWeek)]
928 pub fn months_in_year(this: &PlainDate) -> u32;
929
930 /// The inLeapYear read-only property tells whether the year that the date falls in is a
931 /// leap year or not. Its value is true if the year is a leap year, and false if not.
932 #[wasm_bindgen(method, getter, structural, js_name = inLeapYear)]
933 pub fn in_leap_year(this: &PlainDate) -> bool;
934
935 /// Returns a new `Temporal.PlainDate` object which is the date indicated by date, projected
936 /// into calendar.
937 #[wasm_bindgen(method, js_name = withCalendar)]
938 pub fn with_calendar(this: &PlainDate, calendar: &str) -> PlainDate;
939
940 /// **Parameters:**
941 ///
942 ///- `duration` (`Temporal.Duration` or value convertible to one): The duration to add.
943 ///- `options` (optional object): An object with properties representing options for the addition.
944 ///The following options are recognized:
945 ///- `overflow` (optional string): How to deal with additions that result in out-of-range values.
946 /// Allowed values are `constrain` and `reject`.
947 /// The default is `constrain`.
948 ///
949 ///**Returns:** a new `Temporal.PlainDate` object which is the date indicated by `date` plus `duration`.
950 ///
951 ///This method adds `duration` to `date`, returning a date that is in the future relative to `date`.
952 ///
953 ///The `duration` argument is an object with properties denoting a duration, such as `{ days: 5 }`, or a string such as `P5D`, or a `Temporal.Duration` object.
954 ///If `duration` is not a `Temporal.Duration` object, then it will be converted to one as if it were passed to `Temporal.Duration.from()`.
955 ///
956 ///Some additions may be ambiguous, because months have different lengths.
957 ///For example, adding one month to August 31 would result in September 31, which doesn't exist.
958 ///For these cases, the `overflow` option tells what to do:
959 ///
960 ///- In `constrain` mode (the default), out-of-range values are clamped to the nearest in-range value.
961 ///- In `reject` mode, an addition that would result in an out-of-range value fails, and a `RangeError` is thrown.
962 ///
963 ///Additionally, if the result is earlier or later than the range of dates that `Temporal.PlainDate` can represent (approximately half a million years centered on the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time)), then this method will throw a `RangeError` regardless of `overflow`.
964 ///
965 ///Adding a negative duration is equivalent to subtracting the absolute value of that duration.
966 #[wasm_bindgen(method)]
967 pub fn add(this: &PlainDate, duration: &Duration, options: &JsValue) -> PlainDate;
968
969 /// **Parameters:**
970 ///- `duration` (`Temporal.Duration` or value convertible to one): The duration to subtract.
971 ///- `options` (optional object): An object with properties representing options for the subtraction.
972 ///The following options are recognized:
973 ///- `overflow` (string): How to deal with subtractions that result in out-of-range values.
974 /// Allowed values are `constrain` and `reject`.
975 /// The default is `constrain`.
976 ///
977 ///**Returns:** a new `Temporal.PlainDate` object which is the date indicated by `date` minus `duration`.
978 ///
979 ///This method subtracts `duration` from `date`, returning a date that is in the past relative to `date`.
980 ///
981 ///The `duration` argument is an object with properties denoting a duration, such as `{ days: 5 }`, or a string such as `P5D`, or a `Temporal.Duration` object.
982 ///If `duration` is not a `Temporal.Duration` object, then it will be converted to one as if it were passed to `Temporal.Duration.from()`.
983 ///
984 ///Some subtractions may be ambiguous, because months have different lengths.
985 ///For example, subtracting one month from July 31 would result in June 31, which doesn't exist.
986 ///For these cases, the `overflow` option tells what to do:
987 ///
988 ///- In `constrain` mode (the default), out-of-range values are clamped to the nearest in-range value.
989 ///- In `reject` mode, an addition that would result in an out-of-range value fails, and a `RangeError` is thrown.
990 ///
991 ///Additionally, if the result is earlier or later than the range of dates that `Temporal.PlainDate` can represent (approximately half a million years centered on the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time)), then this method will throw a `RangeError` regardless of `overflow`.
992 ///
993 ///Subtracting a negative duration is equivalent to adding the absolute value of that duration.
994 ///
995 #[wasm_bindgen(method)]
996 pub fn subtract(this: &PlainDate, duration: &Duration, options: &JsValue) -> PlainDate;
997
998 /// This function exists because it's not possible to compare using date == other
999 /// or date === other, due to ambiguity in the primitive representation and between
1000 /// Temporal types.
1001 ///
1002 /// If you don't need to know the order in which the two dates occur, then this function
1003 /// may be less typing and more efficient than Temporal.PlainDate.compare.
1004 ///
1005 /// Note that this function will return false if the two objects have different calendar
1006 /// properties, even if the actual dates are equal.
1007 #[wasm_bindgen(method)]
1008 pub fn equals(this: &PlainDate, other: &PlainDate) -> bool;
1009
1010 /// This method overrides the Object.prototype.toString() method and provides a convenient, unambiguous
1011 /// string representation of date. The string can be passed to Temporal.PlainDate.from() to
1012 /// create a new Temporal.PlainDate object.
1013 #[wasm_bindgen(method, js_name = toString)]
1014 pub fn to_string(this: &PlainDate) -> JsString;
1015
1016 /// This method overrides `Object.prototype.toLocaleString()` to provide a human-readable,
1017 /// language-sensitive representation of duration.
1018 ///
1019 /// The locales and options arguments are the same as in the constructor to Intl.DateTimeFormat.
1020 #[wasm_bindgen(method, js_name = toLocaleString)]
1021 pub fn to_locale_string(this: &PlainDate, locales: &JsValue, options: &JsValue) -> JsString;
1022
1023 /// Returns: a plain object with properties expressing date in the ISO 8601
1024 /// calendar, as well as the value of date.calendar.
1025 ///
1026 /// This method is mainly useful if you are implementing a custom calendar. Most
1027 /// code will not need to use it.
1028 #[wasm_bindgen(method, js_name = getISOFields)]
1029 pub fn get_iso_fields(this: &PlainDate) -> JsValue;
1030
1031 }
1032
1033 pub mod Now {
1034 use super::*;
1035
1036 #[wasm_bindgen]
1037 extern "C" {
1038 #[wasm_bindgen(js_namespace = ["Temporal", "Now"])]
1039 pub fn instant() -> Instant;
1040
1041 #[wasm_bindgen(js_namespace = ["Temporal", "Now"], js_name = zonedDateTime)]
1042 pub fn zoned_date_time(calendar: &str) -> ZonedDateTime;
1043
1044 #[wasm_bindgen(js_namespace = ["Temporal", "Now"], js_name = zonedDateTimeISO)]
1045 pub fn zoned_date_time_iso() -> ZonedDateTime;
1046
1047 #[wasm_bindgen(js_namespace = ["Temporal", "Now"], js_name = plainDate)]
1048 pub fn plain_date(calendar: &str) -> PlainDate;
1049
1050 #[wasm_bindgen(js_namespace = ["Temporal", "Now"], js_name = plainDateISO)]
1051 pub fn plain_date_iso() -> PlainDate;
1052
1053 #[wasm_bindgen(js_namespace = ["Temporal", "Now"], js_name = plainTimeISO)]
1054 pub fn plain_time_iso() -> PlainTime;
1055
1056 }
1057 }