from
Creates a PlainDate from another PlainDate or from a string (ISO 8601) or UTF-16 array.
Parameters
- info:anytype
- anytype
Source
Implementation
pub fn from(info: anytype) !PlainDate {
const T = @TypeOf(info);
if (T == PlainDate) return info.clone();
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 a PlainDate, []const u8, or []const u16"),
}
}