summaryrefslogtreecommitdiffstats
path: root/intl/icu_capi/js/package/lib/ICU4XCustomTimeZone.js
diff options
context:
space:
mode:
Diffstat (limited to 'intl/icu_capi/js/package/lib/ICU4XCustomTimeZone.js')
-rw-r--r--intl/icu_capi/js/package/lib/ICU4XCustomTimeZone.js347
1 files changed, 347 insertions, 0 deletions
diff --git a/intl/icu_capi/js/package/lib/ICU4XCustomTimeZone.js b/intl/icu_capi/js/package/lib/ICU4XCustomTimeZone.js
new file mode 100644
index 0000000000..615f0b2ea8
--- /dev/null
+++ b/intl/icu_capi/js/package/lib/ICU4XCustomTimeZone.js
@@ -0,0 +1,347 @@
+import wasm from "./diplomat-wasm.mjs"
+import * as diplomatRuntime from "./diplomat-runtime.js"
+import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js"
+
+const ICU4XCustomTimeZone_box_destroy_registry = new FinalizationRegistry(underlying => {
+ wasm.ICU4XCustomTimeZone_destroy(underlying);
+});
+
+export class ICU4XCustomTimeZone {
+ #lifetimeEdges = [];
+ constructor(underlying, owned, edges) {
+ this.underlying = underlying;
+ this.#lifetimeEdges.push(...edges);
+ if (owned) {
+ ICU4XCustomTimeZone_box_destroy_registry.register(this, underlying);
+ }
+ }
+
+ static create_from_string(arg_s) {
+ const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s);
+ const diplomat_out = (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_create_from_string(diplomat_receive_buffer, buf_arg_s.ptr, buf_arg_s.size);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = new ICU4XCustomTimeZone(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ buf_arg_s.free();
+ return diplomat_out;
+ }
+
+ static create_empty() {
+ return new ICU4XCustomTimeZone(wasm.ICU4XCustomTimeZone_create_empty(), true, []);
+ }
+
+ static create_utc() {
+ return new ICU4XCustomTimeZone(wasm.ICU4XCustomTimeZone_create_utc(), true, []);
+ }
+
+ try_set_gmt_offset_seconds(arg_offset_seconds) {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_try_set_gmt_offset_seconds(diplomat_receive_buffer, this.underlying, arg_offset_seconds);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = {};
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ }
+
+ clear_gmt_offset() {
+ wasm.ICU4XCustomTimeZone_clear_gmt_offset(this.underlying);
+ }
+
+ gmt_offset_seconds() {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_gmt_offset_seconds(diplomat_receive_buffer, this.underlying);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = (new Int32Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ }
+
+ is_gmt_offset_positive() {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_is_gmt_offset_positive(diplomat_receive_buffer, this.underlying);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ }
+
+ is_gmt_offset_zero() {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_is_gmt_offset_zero(diplomat_receive_buffer, this.underlying);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ }
+
+ gmt_offset_has_minutes() {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_gmt_offset_has_minutes(diplomat_receive_buffer, this.underlying);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ }
+
+ gmt_offset_has_seconds() {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_gmt_offset_has_seconds(diplomat_receive_buffer, this.underlying);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ }
+
+ try_set_time_zone_id(arg_id) {
+ const buf_arg_id = diplomatRuntime.DiplomatBuf.str(wasm, arg_id);
+ const diplomat_out = (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_try_set_time_zone_id(diplomat_receive_buffer, this.underlying, buf_arg_id.ptr, buf_arg_id.size);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = {};
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ buf_arg_id.free();
+ return diplomat_out;
+ }
+
+ try_set_iana_time_zone_id(arg_mapper, arg_id) {
+ const buf_arg_id = diplomatRuntime.DiplomatBuf.str(wasm, arg_id);
+ const diplomat_out = (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_try_set_iana_time_zone_id(diplomat_receive_buffer, this.underlying, arg_mapper.underlying, buf_arg_id.ptr, buf_arg_id.size);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = {};
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ buf_arg_id.free();
+ return diplomat_out;
+ }
+
+ clear_time_zone_id() {
+ wasm.ICU4XCustomTimeZone_clear_time_zone_id(this.underlying);
+ }
+
+ time_zone_id() {
+ return diplomatRuntime.withWriteable(wasm, (writeable) => {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_time_zone_id(diplomat_receive_buffer, this.underlying, writeable);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = {};
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ });
+ }
+
+ try_set_metazone_id(arg_id) {
+ const buf_arg_id = diplomatRuntime.DiplomatBuf.str(wasm, arg_id);
+ const diplomat_out = (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_try_set_metazone_id(diplomat_receive_buffer, this.underlying, buf_arg_id.ptr, buf_arg_id.size);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = {};
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ buf_arg_id.free();
+ return diplomat_out;
+ }
+
+ clear_metazone_id() {
+ wasm.ICU4XCustomTimeZone_clear_metazone_id(this.underlying);
+ }
+
+ metazone_id() {
+ return diplomatRuntime.withWriteable(wasm, (writeable) => {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_metazone_id(diplomat_receive_buffer, this.underlying, writeable);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = {};
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ });
+ }
+
+ try_set_zone_variant(arg_id) {
+ const buf_arg_id = diplomatRuntime.DiplomatBuf.str(wasm, arg_id);
+ const diplomat_out = (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_try_set_zone_variant(diplomat_receive_buffer, this.underlying, buf_arg_id.ptr, buf_arg_id.size);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = {};
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ buf_arg_id.free();
+ return diplomat_out;
+ }
+
+ clear_zone_variant() {
+ wasm.ICU4XCustomTimeZone_clear_zone_variant(this.underlying);
+ }
+
+ zone_variant() {
+ return diplomatRuntime.withWriteable(wasm, (writeable) => {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_zone_variant(diplomat_receive_buffer, this.underlying, writeable);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = {};
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ });
+ }
+
+ set_standard_time() {
+ wasm.ICU4XCustomTimeZone_set_standard_time(this.underlying);
+ }
+
+ set_daylight_time() {
+ wasm.ICU4XCustomTimeZone_set_daylight_time(this.underlying);
+ }
+
+ is_standard_time() {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_is_standard_time(diplomat_receive_buffer, this.underlying);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ }
+
+ is_daylight_time() {
+ return (() => {
+ const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
+ wasm.ICU4XCustomTimeZone_is_daylight_time(diplomat_receive_buffer, this.underlying);
+ const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
+ if (is_ok) {
+ const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ return ok_value;
+ } else {
+ const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
+ wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
+ throw new diplomatRuntime.FFIError(throw_value);
+ }
+ })();
+ }
+
+ maybe_calculate_metazone(arg_metazone_calculator, arg_local_datetime) {
+ wasm.ICU4XCustomTimeZone_maybe_calculate_metazone(this.underlying, arg_metazone_calculator.underlying, arg_local_datetime.underlying);
+ }
+}