TemporalZ

init

Creates a new PlainYearMonth from the given year, month, and optional calendar. Equivalent to the Temporal.PlainYearMonth constructor.

See: Temporal.PlainYearMonth

Parameters

#
year_val:i32
i32
month_val:u8
u8
calendar:?[]const u8
?[]const u8

Source

Implementation

#
pub fn init(year_val: i32, month_val: u8, calendar: ?[]const u8) !PlainYearMonth {
    const cal_kind = if (calendar) |cal| blk: {
        const cal_view = abi.toDiplomatStringView(cal);
        const cal_result = abi.c.temporal_rs_AnyCalendarKind_parse_temporal_calendar_string(cal_view);
        break :blk try abi.extractResult(cal_result);
    } else abi.c.AnyCalendarKind_Iso;

    const overflow = abi.c.ArithmeticOverflow_Constrain;
    const ref_day = abi.c.OptionU8{ .is_ok = false };

    return wrapPlainYearMonth(abi.c.temporal_rs_PlainYearMonth_try_new_with_overflow(
        year_val,
        month_val,
        ref_day,
        cal_kind,
        overflow,
    ));
}