add iso8601 string to timestamp

This commit is contained in:
Emil Lerch 2022-02-16 13:47:19 -08:00
parent 4b26bc884f
commit b44ea5c3e8
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -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