with
Returns a new PlainMonthDay with some fields replaced by new values.
Parameters
- self:PlainMonthDay
- PlainMonthDay
- options:WithOptions
- WithOptions
Source
Implementation
pub fn with(self: PlainMonthDay, options: WithOptions) !PlainMonthDay {
// Build month_code view
const month_code_view = if (options.month_code) |mc|
abi.toDiplomatStringView(mc)
else
abi.c.DiplomatStringView{ .data = null, .len = 0 };
// Build partial date with only the fields we want to modify
const partial_date = abi.c.PartialDate{
.year = .{ .is_ok = false },
.month = .{ .is_ok = false },
.day = if (options.day) |d| abi.toOption(abi.c.OptionU8, d) else .{ .is_ok = false },
.month_code = month_code_view,
.era = .{ .data = null, .len = 0 },
.era_year = .{ .is_ok = false },
.calendar = abi.c.AnyCalendarKind_Iso,
};
const overflow = abi.c.ArithmeticOverflow_option{
.is_ok = true,
.unnamed_0 = .{ .ok = abi.c.ArithmeticOverflow_Constrain },
};
return wrapPlainMonthDay(abi.c.temporal_rs_PlainMonthDay_with(
self._inner,
partial_date,
overflow,
));
}