Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Date = packed struct {
- year: i32,
- month: u8,
- day: u8,
- hour: u8,
- minute: u8,
- nanosecond: u64,
- timezone: [3]u8 = "UTC",
- fn parse(input: []const u8, comptime format: []const u8) Date {
- return Date{
- .year = 2018,
- .month = 3,
- .day = 5,
- .hour = 0,
- .minute = 0,
- .nanosecond = 0,
- };
- }
- };
- test "parsing" {
- const input = "2018-03-05 00:00:00";
- const date = Date.parse(input, "YYYY-MM-DD hh:mm:ss");
- }
Advertisement
Add Comment
Please, Sign In to add comment