DateFormatter.mjs (41970B)
1 // generated by diplomat-tool 2 import { DataProvider } from "./DataProvider.mjs" 3 import { Date } from "./Date.mjs" 4 import { DateTimeAlignment } from "./DateTimeAlignment.mjs" 5 import { DateTimeFormatterLoadError } from "./DateTimeFormatterLoadError.mjs" 6 import { DateTimeLength } from "./DateTimeLength.mjs" 7 import { DateTimeMismatchedCalendarError } from "./DateTimeMismatchedCalendarError.mjs" 8 import { IsoDate } from "./IsoDate.mjs" 9 import { Locale } from "./Locale.mjs" 10 import { YearStyle } from "./YearStyle.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 `DateTimeFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html) for more information. 17 */ 18 const DateFormatter_box_destroy_registry = new FinalizationRegistry((ptr) => { 19 wasm.icu4x_DateFormatter_destroy_mv1(ptr); 20 }); 21 22 export class DateFormatter { 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("DateFormatter 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 DateFormatter_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 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 52 * 53 * See the [Rust documentation for `D`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.D.html) for more information. 54 * 55 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.D.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.D.html#method.for_length) 56 */ 57 static createD(locale, length, alignment) { 58 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 59 60 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 61 62 63 const result = wasm.icu4x_DateFormatter_create_d_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 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)])); 64 65 try { 66 if (!diplomatReceive.resultFlag) { 67 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 68 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 69 } 70 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 71 } 72 73 finally { 74 functionCleanupArena.free(); 75 76 diplomatReceive.free(); 77 } 78 } 79 80 /** 81 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 82 * 83 * See the [Rust documentation for `D`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.D.html) for more information. 84 * 85 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.D.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.D.html#method.for_length) 86 */ 87 static createDWithProvider(provider, locale, length, alignment) { 88 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 89 90 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 91 92 93 const result = wasm.icu4x_DateFormatter_create_d_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(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 94 95 try { 96 if (!diplomatReceive.resultFlag) { 97 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 98 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 99 } 100 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 101 } 102 103 finally { 104 functionCleanupArena.free(); 105 106 diplomatReceive.free(); 107 } 108 } 109 110 /** 111 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 112 * 113 * See the [Rust documentation for `MD`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MD.html) for more information. 114 * 115 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MD.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MD.html#method.for_length) 116 */ 117 static createMd(locale, length, alignment) { 118 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 119 120 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 121 122 123 const result = wasm.icu4x_DateFormatter_create_md_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 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)])); 124 125 try { 126 if (!diplomatReceive.resultFlag) { 127 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 128 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 129 } 130 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 131 } 132 133 finally { 134 functionCleanupArena.free(); 135 136 diplomatReceive.free(); 137 } 138 } 139 140 /** 141 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 142 * 143 * See the [Rust documentation for `MD`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MD.html) for more information. 144 * 145 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MD.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MD.html#method.for_length) 146 */ 147 static createMdWithProvider(provider, locale, length, alignment) { 148 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 149 150 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 151 152 153 const result = wasm.icu4x_DateFormatter_create_md_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(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 154 155 try { 156 if (!diplomatReceive.resultFlag) { 157 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 158 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 159 } 160 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 161 } 162 163 finally { 164 functionCleanupArena.free(); 165 166 diplomatReceive.free(); 167 } 168 } 169 170 /** 171 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 172 * 173 * See the [Rust documentation for `YMD`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMD.html) for more information. 174 * 175 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMD.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMD.html#method.with_year_style), [3](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMD.html#method.for_length) 176 */ 177 static createYmd(locale, length, alignment, yearStyle) { 178 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 179 180 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 181 182 183 const result = wasm.icu4x_DateFormatter_create_ymd_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 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)]), ...diplomatRuntime.optionToArgsForCalling(yearStyle, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 184 185 try { 186 if (!diplomatReceive.resultFlag) { 187 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 188 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 189 } 190 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 191 } 192 193 finally { 194 functionCleanupArena.free(); 195 196 diplomatReceive.free(); 197 } 198 } 199 200 /** 201 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 202 * 203 * See the [Rust documentation for `YMD`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMD.html) for more information. 204 * 205 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMD.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMD.html#method.with_year_style), [3](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMD.html#method.for_length) 206 */ 207 static createYmdWithProvider(provider, locale, length, alignment, yearStyle) { 208 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 209 210 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 211 212 213 const result = wasm.icu4x_DateFormatter_create_ymd_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(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(yearStyle, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 214 215 try { 216 if (!diplomatReceive.resultFlag) { 217 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 218 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 219 } 220 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 221 } 222 223 finally { 224 functionCleanupArena.free(); 225 226 diplomatReceive.free(); 227 } 228 } 229 230 /** 231 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 232 * 233 * See the [Rust documentation for `DE`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.DE.html) for more information. 234 * 235 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.DE.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.DE.html#method.for_length) 236 */ 237 static createDe(locale, length, alignment) { 238 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 239 240 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 241 242 243 const result = wasm.icu4x_DateFormatter_create_de_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 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)])); 244 245 try { 246 if (!diplomatReceive.resultFlag) { 247 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 248 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 249 } 250 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 251 } 252 253 finally { 254 functionCleanupArena.free(); 255 256 diplomatReceive.free(); 257 } 258 } 259 260 /** 261 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 262 * 263 * See the [Rust documentation for `DE`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.DE.html) for more information. 264 * 265 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.DE.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.DE.html#method.for_length) 266 */ 267 static createDeWithProvider(provider, locale, length, alignment) { 268 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 269 270 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 271 272 273 const result = wasm.icu4x_DateFormatter_create_de_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(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 274 275 try { 276 if (!diplomatReceive.resultFlag) { 277 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 278 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 279 } 280 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 281 } 282 283 finally { 284 functionCleanupArena.free(); 285 286 diplomatReceive.free(); 287 } 288 } 289 290 /** 291 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 292 * 293 * See the [Rust documentation for `MDE`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MDE.html) for more information. 294 * 295 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MDE.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MDE.html#method.for_length) 296 */ 297 static createMde(locale, length, alignment) { 298 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 299 300 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 301 302 303 const result = wasm.icu4x_DateFormatter_create_mde_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 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)])); 304 305 try { 306 if (!diplomatReceive.resultFlag) { 307 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 308 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 309 } 310 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 311 } 312 313 finally { 314 functionCleanupArena.free(); 315 316 diplomatReceive.free(); 317 } 318 } 319 320 /** 321 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 322 * 323 * See the [Rust documentation for `MDE`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MDE.html) for more information. 324 * 325 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MDE.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.MDE.html#method.for_length) 326 */ 327 static createMdeWithProvider(provider, locale, length, alignment) { 328 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 329 330 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 331 332 333 const result = wasm.icu4x_DateFormatter_create_mde_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(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 334 335 try { 336 if (!diplomatReceive.resultFlag) { 337 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 338 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 339 } 340 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 341 } 342 343 finally { 344 functionCleanupArena.free(); 345 346 diplomatReceive.free(); 347 } 348 } 349 350 /** 351 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 352 * 353 * See the [Rust documentation for `YMDE`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMDE.html) for more information. 354 * 355 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMDE.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMDE.html#method.with_year_style), [3](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMDE.html#method.for_length) 356 */ 357 static createYmde(locale, length, alignment, yearStyle) { 358 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 359 360 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 361 362 363 const result = wasm.icu4x_DateFormatter_create_ymde_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 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)]), ...diplomatRuntime.optionToArgsForCalling(yearStyle, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 364 365 try { 366 if (!diplomatReceive.resultFlag) { 367 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 368 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 369 } 370 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 371 } 372 373 finally { 374 functionCleanupArena.free(); 375 376 diplomatReceive.free(); 377 } 378 } 379 380 /** 381 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 382 * 383 * See the [Rust documentation for `YMDE`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMDE.html) for more information. 384 * 385 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMDE.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMDE.html#method.with_year_style), [3](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YMDE.html#method.for_length) 386 */ 387 static createYmdeWithProvider(provider, locale, length, alignment, yearStyle) { 388 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 389 390 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 391 392 393 const result = wasm.icu4x_DateFormatter_create_ymde_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(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(yearStyle, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 394 395 try { 396 if (!diplomatReceive.resultFlag) { 397 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 398 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 399 } 400 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 401 } 402 403 finally { 404 functionCleanupArena.free(); 405 406 diplomatReceive.free(); 407 } 408 } 409 410 /** 411 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 412 * 413 * See the [Rust documentation for `E`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.E.html) for more information. 414 * 415 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.E.html#method.for_length) 416 */ 417 static createE(locale, length) { 418 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 419 420 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 421 422 423 const result = wasm.icu4x_DateFormatter_create_e_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 424 425 try { 426 if (!diplomatReceive.resultFlag) { 427 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 428 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 429 } 430 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 431 } 432 433 finally { 434 functionCleanupArena.free(); 435 436 diplomatReceive.free(); 437 } 438 } 439 440 /** 441 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 442 * 443 * See the [Rust documentation for `E`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.E.html) for more information. 444 * 445 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.E.html#method.for_length) 446 */ 447 static createEWithProvider(provider, locale, length) { 448 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 449 450 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 451 452 453 const result = wasm.icu4x_DateFormatter_create_e_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)])); 454 455 try { 456 if (!diplomatReceive.resultFlag) { 457 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 458 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 459 } 460 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 461 } 462 463 finally { 464 functionCleanupArena.free(); 465 466 diplomatReceive.free(); 467 } 468 } 469 470 /** 471 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 472 * 473 * See the [Rust documentation for `M`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.M.html) for more information. 474 * 475 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.M.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.M.html#method.for_length) 476 */ 477 static createM(locale, length, alignment) { 478 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 479 480 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 481 482 483 const result = wasm.icu4x_DateFormatter_create_m_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 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)])); 484 485 try { 486 if (!diplomatReceive.resultFlag) { 487 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 488 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 489 } 490 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 491 } 492 493 finally { 494 functionCleanupArena.free(); 495 496 diplomatReceive.free(); 497 } 498 } 499 500 /** 501 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 502 * 503 * See the [Rust documentation for `M`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.M.html) for more information. 504 * 505 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.M.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.M.html#method.for_length) 506 */ 507 static createMWithProvider(provider, locale, length, alignment) { 508 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 509 510 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 511 512 513 const result = wasm.icu4x_DateFormatter_create_m_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(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 514 515 try { 516 if (!diplomatReceive.resultFlag) { 517 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 518 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 519 } 520 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 521 } 522 523 finally { 524 functionCleanupArena.free(); 525 526 diplomatReceive.free(); 527 } 528 } 529 530 /** 531 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 532 * 533 * See the [Rust documentation for `YM`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YM.html) for more information. 534 * 535 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YM.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YM.html#method.with_year_style), [3](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YM.html#method.for_length) 536 */ 537 static createYm(locale, length, alignment, yearStyle) { 538 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 539 540 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 541 542 543 const result = wasm.icu4x_DateFormatter_create_ym_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 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)]), ...diplomatRuntime.optionToArgsForCalling(yearStyle, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 544 545 try { 546 if (!diplomatReceive.resultFlag) { 547 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 548 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 549 } 550 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 551 } 552 553 finally { 554 functionCleanupArena.free(); 555 556 diplomatReceive.free(); 557 } 558 } 559 560 /** 561 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 562 * 563 * See the [Rust documentation for `YM`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YM.html) for more information. 564 * 565 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YM.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YM.html#method.with_year_style), [3](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.YM.html#method.for_length) 566 */ 567 static createYmWithProvider(provider, locale, length, alignment, yearStyle) { 568 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 569 570 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 571 572 573 const result = wasm.icu4x_DateFormatter_create_ym_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(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(yearStyle, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 574 575 try { 576 if (!diplomatReceive.resultFlag) { 577 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 578 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 579 } 580 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 581 } 582 583 finally { 584 functionCleanupArena.free(); 585 586 diplomatReceive.free(); 587 } 588 } 589 590 /** 591 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 592 * 593 * See the [Rust documentation for `Y`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.Y.html) for more information. 594 * 595 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.Y.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.Y.html#method.with_year_style), [3](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.Y.html#method.for_length) 596 */ 597 static createY(locale, length, alignment, yearStyle) { 598 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 599 600 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 601 602 603 const result = wasm.icu4x_DateFormatter_create_y_mv1(diplomatReceive.buffer, locale.ffiValue, ...diplomatRuntime.optionToArgsForCalling(length, 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)]), ...diplomatRuntime.optionToArgsForCalling(yearStyle, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 604 605 try { 606 if (!diplomatReceive.resultFlag) { 607 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 608 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 609 } 610 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 611 } 612 613 finally { 614 functionCleanupArena.free(); 615 616 diplomatReceive.free(); 617 } 618 } 619 620 /** 621 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. 622 * 623 * See the [Rust documentation for `Y`](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.Y.html) for more information. 624 * 625 * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.Y.html#method.with_alignment), [2](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.Y.html#method.with_year_style), [3](https://docs.rs/icu/latest/icu/datetime/fieldsets/struct.Y.html#method.for_length) 626 */ 627 static createYWithProvider(provider, locale, length, alignment, yearStyle) { 628 let functionCleanupArena = new diplomatRuntime.CleanupArena(); 629 630 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 631 632 633 const result = wasm.icu4x_DateFormatter_create_y_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(alignment, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(yearStyle, 4, 4, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])); 634 635 try { 636 if (!diplomatReceive.resultFlag) { 637 const cause = new DateTimeFormatterLoadError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 638 throw new globalThis.Error('DateTimeFormatterLoadError: ' + cause.value, { cause }); 639 } 640 return new DateFormatter(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); 641 } 642 643 finally { 644 functionCleanupArena.free(); 645 646 diplomatReceive.free(); 647 } 648 } 649 650 /** 651 * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format) for more information. 652 */ 653 formatIso(date) { 654 const write = new diplomatRuntime.DiplomatWriteBuf(wasm); 655 656 wasm.icu4x_DateFormatter_format_iso_mv1(this.ffiValue, date.ffiValue, write.buffer); 657 658 try { 659 return write.readString8(); 660 } 661 662 finally { 663 write.free(); 664 } 665 } 666 667 /** 668 * See the [Rust documentation for `format_same_calendar`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format_same_calendar) for more information. 669 */ 670 formatSameCalendar(date) { 671 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 13, 4, true); 672 673 const write = new diplomatRuntime.DiplomatWriteBuf(wasm); 674 675 676 const result = wasm.icu4x_DateFormatter_format_same_calendar_mv1(diplomatReceive.buffer, this.ffiValue, date.ffiValue, write.buffer); 677 678 try { 679 if (!diplomatReceive.resultFlag) { 680 const cause = DateTimeMismatchedCalendarError._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); 681 throw new globalThis.Error('DateTimeMismatchedCalendarError: ' + cause.toString(), { cause }); 682 } 683 return write.readString8(); 684 } 685 686 finally { 687 diplomatReceive.free(); 688 write.free(); 689 } 690 } 691 692 constructor(symbol, ptr, selfEdge) { 693 return this.#internalConstructor(...arguments) 694 } 695 }