| author | |
| committer | |
| log | eae2ed2910b661553c1d25f03fc67c66c449e28f |
| tree | e8e8d6ba7d2ff1460a579d598773231e32b9b87e |
| parent | 603c995cec837b9864299a0affeefbf76f2cfab0 |
| signature |
2 files changed, 4 insertions(+), 6 deletions(-)
README.md+1-1| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 |  |
| 4 | 4 | [](https://github.com/nektro/zig-time/blob/master/LICENSE) |
| 5 | 5 | [](https://github.com/sponsors/nektro) |
| 6 | [](https://ziglang.org/) | |
| 6 | [](https://ziglang.org/) | |
| 7 | 7 | [](https://github.com/nektro/zigmod) |
| 8 | 8 | |
| 9 | 9 | Exposes a `DateTime` structure that can be initialized and acted upon using various methods. All public methods return a new structure. |
time.zig+3-5| ... | ... | @@ -250,9 +250,7 @@ pub const DateTime = struct { |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /// fmt is based on https://momentjs.com/docs/#/displaying/format/ |
| 253 | pub fn format(self: DateTime, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) !void { | |
| 254 | _ = options; | |
| 255 | ||
| 253 | pub fn formatFmt(self: DateTime, comptime fmt: string, writer: anytype) !void { | |
| 256 | 254 | if (fmt.len == 0) @compileError("DateTime: format string can't be empty"); |
| 257 | 255 | |
| 258 | 256 | @setEvalBranchQuota(100000); |
| ... | ... | @@ -358,10 +356,10 @@ pub const DateTime = struct { |
| 358 | 356 | } |
| 359 | 357 | |
| 360 | 358 | pub fn formatAlloc(self: DateTime, alloc: std.mem.Allocator, comptime fmt: string) !string { |
| 361 | var list = std.array_list.Managed(u8).init(alloc); | |
| 359 | var list = std.Io.Writer.Allocating.init(alloc); | |
| 362 | 360 | defer list.deinit(); |
| 363 | 361 | |
| 364 | try self.format(fmt, .{}, list.writer()); | |
| 362 | try self.formatFmt(fmt, &list.writer); | |
| 365 | 363 | return list.toOwnedSlice(); |
| 366 | 364 | } |
| 367 | 365 |