from
Parse an RFC 9557 string (Temporal.Instant.from) or from another Temporal.Instant.
Parameters
- info:anytype
- anytype
Source
Implementation
pub fn from(info: anytype) !Instant {
const T = @TypeOf(info);
if (T == Instant) return info.clone();
// Handle string types (both literals and slices)
const type_info = @typeInfo(T);
switch (type_info) {
.pointer => {
const ptr = type_info.pointer;
const ChildType = switch (@typeInfo(ptr.child)) {
.array => |arr| arr.child,
else => ptr.child,
};
if (ChildType == u8) return fromUtf8(info);
if (ChildType == u16) return fromUtf16(info);
},
else => @compileError("from() expects an Instant, []const u8, or []const u16"),
}
}