ZonedTimeFormatter.mjs (34188B)
1 // generated by diplomat-tool 2 import { DataProvider } from "./DataProvider.mjs" 3 import { DateTimeAlignment } from "./DateTimeAlignment.mjs" 4 import { DateTimeFormatterLoadError } from "./DateTimeFormatterLoadError.mjs" 5 import { DateTimeLength } from "./DateTimeLength.mjs" 6 import { DateTimeWriteError } from "./DateTimeWriteError.mjs" 7 import { Locale } from "./Locale.mjs" 8 import { Time } from "./Time.mjs" 9 import { TimePrecision } from "./TimePrecision.mjs" 10 import { TimeZoneInfo } from "./TimeZoneInfo.mjs" 11 import wasm from "./diplomat-wasm.mjs"; 12 import * as diplomatRuntime from "./diplomat-runtime.mjs"; 13 14 15 /** 16 * See the [Rust documentation for `NoCalendarFormatter`](https://docs.rs/icu/latest/icu/datetime/type.NoCalendarFormatter.html) for more information. 17 */ 18 const ZonedTimeFormatter_box_destroy_registry = new FinalizationRegistry((ptr) => { 19 wasm.icu4x_ZonedTimeFormatter_destroy_mv1(ptr); 20 }); 21 22 export class ZonedTimeFormatter { 23 // Internal ptr reference: 24 #ptr = null; 25 26 // Lifetimes are only to keep dependencies alive. 27 // Since JS won't garbage collect until there are no incoming edges. 28 #selfEdge = []; 29 30 #internalConstructor(symbol, ptr, selfEdge) { 31 if (symbol !== diplomatRuntime.internalConstructor) { 32 console.error("ZonedTimeFormatter is an Opaque type. You cannot call its constructor."); 33 return; 34 } 35 this.#ptr = ptr; 36 this.#selfEdge = selfEdge; 37 38 // Are we being borrowed? If not, we can register. 39 if (this.#selfEdge.length === 0) { 40 ZonedTimeFormatter_box_destroy_registry.register(this, this.#ptr); 41 } 42 43 return this; 44 } 45 get ffiValue() { 46 return this.#ptr; 47 } 48 49 50 /** 51 * Creates a zoned formatter based on a non-zoned formatter. 52 * 53 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 54 * or else unexpected behavior may occur! 55 * 56 * See the [Rust documentation for `SpecificLong`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.SpecificLong.html) for more information. 57 */ 58 static createSpecificLong(locale, length, timePrecision, alignment) { 59 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 60 61 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 62 63 64 const result = wasm.icu4x_ZonedTimeFormatter_create_specific_long_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 65 66 try { 67 if (!diplomatReceive.resultFlag) { 68 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 69 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 70 } 71 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 72 } 73 74 finally { 75 functionCleanupArena.free(); 76 77 diplomatReceive.free(); 78 } 79 } 80 81 /** 82 * Creates a zoned formatter based on a non-zoned formatter. 83 * 84 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 85 * or else unexpected behavior may occur! 86 * 87 * See the [Rust documentation for `SpecificLong`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.SpecificLong.html) for more information. 88 */ 89 static createSpecificLongWithProvider(provider, locale, length, timePrecision, alignment) { 90 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 91 92 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 93 94 95 const result = wasm.icu4x_ZonedTimeFormatter_create_specific_long_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 96 97 try { 98 if (!diplomatReceive.resultFlag) { 99 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 100 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 101 } 102 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 103 } 104 105 finally { 106 functionCleanupArena.free(); 107 108 diplomatReceive.free(); 109 } 110 } 111 112 /** 113 * Creates a zoned formatter based on a non-zoned formatter. 114 * 115 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 116 * or else unexpected behavior may occur! 117 * 118 * See the [Rust documentation for `SpecificShort`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.SpecificShort.html) for more information. 119 */ 120 static createSpecificShort(locale, length, timePrecision, alignment) { 121 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 122 123 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 124 125 126 const result = wasm.icu4x_ZonedTimeFormatter_create_specific_short_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 127 128 try { 129 if (!diplomatReceive.resultFlag) { 130 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 131 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 132 } 133 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 134 } 135 136 finally { 137 functionCleanupArena.free(); 138 139 diplomatReceive.free(); 140 } 141 } 142 143 /** 144 * Creates a zoned formatter based on a non-zoned formatter. 145 * 146 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 147 * or else unexpected behavior may occur! 148 * 149 * See the [Rust documentation for `SpecificShort`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.SpecificShort.html) for more information. 150 */ 151 static createSpecificShortWithProvider(provider, locale, length, timePrecision, alignment) { 152 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 153 154 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 155 156 157 const result = wasm.icu4x_ZonedTimeFormatter_create_specific_short_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 158 159 try { 160 if (!diplomatReceive.resultFlag) { 161 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 162 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 163 } 164 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 165 } 166 167 finally { 168 functionCleanupArena.free(); 169 170 diplomatReceive.free(); 171 } 172 } 173 174 /** 175 * Creates a zoned formatter based on a non-zoned formatter. 176 * 177 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 178 * or else unexpected behavior may occur! 179 * 180 * See the [Rust documentation for `LocalizedOffsetLong`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.LocalizedOffsetLong.html) for more information. 181 */ 182 static createLocalizedOffsetLong(locale, length, timePrecision, alignment) { 183 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 184 185 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 186 187 188 const result = wasm.icu4x_ZonedTimeFormatter_create_localized_offset_long_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 189 190 try { 191 if (!diplomatReceive.resultFlag) { 192 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 193 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 194 } 195 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 196 } 197 198 finally { 199 functionCleanupArena.free(); 200 201 diplomatReceive.free(); 202 } 203 } 204 205 /** 206 * Creates a zoned formatter based on a non-zoned formatter. 207 * 208 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 209 * or else unexpected behavior may occur! 210 * 211 * See the [Rust documentation for `LocalizedOffsetLong`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.LocalizedOffsetLong.html) for more information. 212 */ 213 static createLocalizedOffsetLongWithProvider(provider, locale, length, timePrecision, alignment) { 214 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 215 216 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 217 218 219 const result = wasm.icu4x_ZonedTimeFormatter_create_localized_offset_long_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 220 221 try { 222 if (!diplomatReceive.resultFlag) { 223 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 224 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 225 } 226 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 227 } 228 229 finally { 230 functionCleanupArena.free(); 231 232 diplomatReceive.free(); 233 } 234 } 235 236 /** 237 * Creates a zoned formatter based on a non-zoned formatter. 238 * 239 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 240 * or else unexpected behavior may occur! 241 * 242 * See the [Rust documentation for `LocalizedOffsetShort`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.LocalizedOffsetShort.html) for more information. 243 */ 244 static createLocalizedOffsetShort(locale, length, timePrecision, alignment) { 245 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 246 247 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 248 249 250 const result = wasm.icu4x_ZonedTimeFormatter_create_localized_offset_short_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 251 252 try { 253 if (!diplomatReceive.resultFlag) { 254 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 255 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 256 } 257 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 258 } 259 260 finally { 261 functionCleanupArena.free(); 262 263 diplomatReceive.free(); 264 } 265 } 266 267 /** 268 * Creates a zoned formatter based on a non-zoned formatter. 269 * 270 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 271 * or else unexpected behavior may occur! 272 * 273 * See the [Rust documentation for `LocalizedOffsetShort`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.LocalizedOffsetShort.html) for more information. 274 */ 275 static createLocalizedOffsetShortWithProvider(provider, locale, length, timePrecision, alignment) { 276 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 277 278 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 279 280 281 const result = wasm.icu4x_ZonedTimeFormatter_create_localized_offset_short_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 282 283 try { 284 if (!diplomatReceive.resultFlag) { 285 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 286 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 287 } 288 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 289 } 290 291 finally { 292 functionCleanupArena.free(); 293 294 diplomatReceive.free(); 295 } 296 } 297 298 /** 299 * Creates a zoned formatter based on a non-zoned formatter. 300 * 301 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 302 * or else unexpected behavior may occur! 303 * 304 * See the [Rust documentation for `GenericLong`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.GenericLong.html) for more information. 305 */ 306 static createGenericLong(locale, length, timePrecision, alignment) { 307 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 308 309 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 310 311 312 const result = wasm.icu4x_ZonedTimeFormatter_create_generic_long_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 313 314 try { 315 if (!diplomatReceive.resultFlag) { 316 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 317 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 318 } 319 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 320 } 321 322 finally { 323 functionCleanupArena.free(); 324 325 diplomatReceive.free(); 326 } 327 } 328 329 /** 330 * Creates a zoned formatter based on a non-zoned formatter. 331 * 332 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 333 * or else unexpected behavior may occur! 334 * 335 * See the [Rust documentation for `GenericLong`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.GenericLong.html) for more information. 336 */ 337 static createGenericLongWithProvider(provider, locale, length, timePrecision, alignment) { 338 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 339 340 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 341 342 343 const result = wasm.icu4x_ZonedTimeFormatter_create_generic_long_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 344 345 try { 346 if (!diplomatReceive.resultFlag) { 347 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 348 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 349 } 350 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 351 } 352 353 finally { 354 functionCleanupArena.free(); 355 356 diplomatReceive.free(); 357 } 358 } 359 360 /** 361 * Creates a zoned formatter based on a non-zoned formatter. 362 * 363 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 364 * or else unexpected behavior may occur! 365 * 366 * See the [Rust documentation for `GenericShort`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.GenericShort.html) for more information. 367 */ 368 static createGenericShort(locale, length, timePrecision, alignment) { 369 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 370 371 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 372 373 374 const result = wasm.icu4x_ZonedTimeFormatter_create_generic_short_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 375 376 try { 377 if (!diplomatReceive.resultFlag) { 378 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 379 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 380 } 381 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 382 } 383 384 finally { 385 functionCleanupArena.free(); 386 387 diplomatReceive.free(); 388 } 389 } 390 391 /** 392 * Creates a zoned formatter based on a non-zoned formatter. 393 * 394 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 395 * or else unexpected behavior may occur! 396 * 397 * See the [Rust documentation for `GenericShort`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.GenericShort.html) for more information. 398 */ 399 static createGenericShortWithProvider(provider, locale, length, timePrecision, alignment) { 400 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 401 402 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 403 404 405 const result = wasm.icu4x_ZonedTimeFormatter_create_generic_short_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 406 407 try { 408 if (!diplomatReceive.resultFlag) { 409 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 410 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 411 } 412 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 413 } 414 415 finally { 416 functionCleanupArena.free(); 417 418 diplomatReceive.free(); 419 } 420 } 421 422 /** 423 * Creates a zoned formatter based on a non-zoned formatter. 424 * 425 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 426 * or else unexpected behavior may occur! 427 * 428 * See the [Rust documentation for `Location`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.Location.html) for more information. 429 */ 430 static createLocation(locale, length, timePrecision, alignment) { 431 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 432 433 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 434 435 436 const result = wasm.icu4x_ZonedTimeFormatter_create_location_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 437 438 try { 439 if (!diplomatReceive.resultFlag) { 440 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 441 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 442 } 443 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 444 } 445 446 finally { 447 functionCleanupArena.free(); 448 449 diplomatReceive.free(); 450 } 451 } 452 453 /** 454 * Creates a zoned formatter based on a non-zoned formatter. 455 * 456 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 457 * or else unexpected behavior may occur! 458 * 459 * See the [Rust documentation for `Location`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.Location.html) for more information. 460 */ 461 static createLocationWithProvider(provider, locale, length, timePrecision, alignment) { 462 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 463 464 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 465 466 467 const result = wasm.icu4x_ZonedTimeFormatter_create_location_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 468 469 try { 470 if (!diplomatReceive.resultFlag) { 471 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 472 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 473 } 474 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 475 } 476 477 finally { 478 functionCleanupArena.free(); 479 480 diplomatReceive.free(); 481 } 482 } 483 484 /** 485 * Creates a zoned formatter based on a non-zoned formatter. 486 * 487 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 488 * or else unexpected behavior may occur! 489 * 490 * See the [Rust documentation for `ExemplarCity`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.ExemplarCity.html) for more information. 491 */ 492 static createExemplarCity(locale, length, timePrecision, alignment) { 493 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 494 495 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 496 497 498 const result = wasm.icu4x_ZonedTimeFormatter_create_exemplar_city_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 499 500 try { 501 if (!diplomatReceive.resultFlag) { 502 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 503 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 504 } 505 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 506 } 507 508 finally { 509 functionCleanupArena.free(); 510 511 diplomatReceive.free(); 512 } 513 } 514 515 /** 516 * Creates a zoned formatter based on a non-zoned formatter. 517 * 518 * Caution: The locale provided here must match the locale used to construct the non-zoned formatter, 519 * or else unexpected behavior may occur! 520 * 521 * See the [Rust documentation for `ExemplarCity`](https://docs.rs/icu/latest/icu/datetime/fieldsets/zone/struct.ExemplarCity.html) for more information. 522 */ 523 static createExemplarCityWithProvider(provider, locale, length, timePrecision, alignment) { 524 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 525 526 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 527 528 529 const result = wasm.icu4x_ZonedTimeFormatter_create_exemplar_city_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(timePrecision, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 530 531 try { 532 if (!diplomatReceive.resultFlag) { 533 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 534 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 535 } 536 return new ZonedTimeFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 537 } 538 539 finally { 540 functionCleanupArena.free(); 541 542 diplomatReceive.free(); 543 } 544 } 545 546 /** 547 * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.FixedCalendarDateTimeFormatter.html#method.format) for more information. 548 */ 549 format(time, zone) { 550 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 551 552 const write = new diplomatRuntime.DiplomatWriteBuf(wasm); 553 554 555 const result = wasm.icu4x_ZonedTimeFormatter_format_mv1(diplomatReceive.buffer, this.ffiValue, time.ffiValue, zone.ffiValue, write.buffer); 556 557 try { 558 if (!diplomatReceive.resultFlag) { 559 const cause = new DateTimeWriteError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 560 throw new globalThis.Error('DateTimeWriteError: ' + cause.value, { cause }); 561 } 562 return write.readString8(); 563 } 564 565 finally { 566 diplomatReceive.free(); 567 write.free(); 568 } 569 } 570 571 constructor(symbol, ptr, selfEdge) { 572 return this.#internalConstructor(...arguments) 573 } 574 }