diff --git a/ulid.zig b/ulid.zig index c8c10e60c0f5412cda33f5bdc1a689f98bc73896..de000254341408e7be3d4fd5b19213e129b8509b 100644 --- a/ulid.zig +++ b/ulid.zig @@ -54,9 +54,13 @@ pub const ULID = struct { pub const fromString = readField; pub const toString = bindField; - pub fn format(self: ULID, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) @TypeOf(writer).Error!void { + pub fn format(self: ULID, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { _ = fmt; _ = options; - try writer.writeAll(self.toString()); + + var buf: [26]u8 = undefined; + base32.formatInt(u48, self.timestamp, buf[0..10]); + base32.formatInt(u80, self.randomnes, buf[10..26]); + try writer.writeAll(&buf); } };