toString
Returns a string representing this instant in the RFC 9557 format, optionally using a time zone.
Parameters
- self:Instant
- Instant
- allocator:std.mem.Allocator
- std.mem.Allocator
- opts:ToStringOptions
- ToStringOptions
Source
Implementation
pub fn toString(self: Instant, allocator: std.mem.Allocator, opts: ToStringOptions) ![]u8 {
const zone_opt = if (opts.time_zone) |tz| abi.toTimeZoneOption(tz._inner) else abi.toTimeZoneOption(null);
const rounding = optsToRounding(opts);
var write = abi.DiplomatWrite.init(allocator);
defer write.deinit();
const res = abi.c.temporal_rs_Instant_to_ixdtf_string_with_compiled_data(self._inner, zone_opt, rounding, &write.inner);
try handleVoidResult(res);
return try write.toOwnedSlice();
}