| ... | ... | @@ -1,5 +1,21 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const string = []const u8; |
| 3 | const time = @import("time"); |
| 2 | 4 | |
| 3 | | pub fn main() anyerror!void { |
| 5 | pub fn main() !void { |
| 4 | 6 | std.log.info("All your codebase are belong to us.", .{}); |
| 5 | 7 | } |
| 8 | |
| 9 | fn assertOk(input: u64, expected: string) !void { |
| 10 | const alloc = std.testing.allocator; |
| 11 | |
| 12 | const actual = try time.DateTime.initUnix(input).formatAlloc(alloc, "YYYY-MM-DD HH:mm:ss"); |
| 13 | defer alloc.free(actual); |
| 14 | |
| 15 | try std.testing.expectEqualStrings(expected, actual); |
| 16 | } |
| 17 | |
| 18 | // zig fmt: off |
| 19 | test { try assertOk(0, "1970-01-01 00:00:00"); } |
| 20 | test { try assertOk(1257894000, "2009-11-10 23:00:00"); } |
| 21 | test { try assertOk(1634858430, "2021-10-21 23:20:30"); } |