From b44ea5c3e8487f50f2ac7f616b72c53bd627c9d6 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 16 Feb 2022 13:47:19 -0800 Subject: [PATCH] add iso8601 string to timestamp --- src/date.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/date.zig b/src/date.zig index 479a809..b581456 100644 --- a/src/date.zig +++ b/src/date.zig @@ -57,6 +57,10 @@ pub fn timestampToDateTime(timestamp: i64) DateTime { return DateTime{ .day = day, .month = month, .year = year, .hour = hours, .minute = minutes, .second = seconds }; } +pub fn parseIso8601ToTimestamp(data: []const u8) !i64 { + return try dateTimeToTimestamp(try parseIso8601ToDateTime(data)); +} + const IsoParsingState = enum { Start, Year, Month, Day, Hour, Minute, Second, Millisecond, End }; /// Converts a string to a timestamp value. May not handle dates before the /// epoch