I want to parse time strings with implicit precision, so parse_datetime("2018") would be a valid timestamp with precision YYYY. How much rewriting of https://github.com/gleam-lang/time/blob/2b63bbc3795489ca8658dd0e0b7452c7eb214aeb/src/gleam/time/timestamp.gleam#L533 would I need to do to only go through the bytes once and get timestamp + precision? Or what approach in general would you take for this
import gleam/time/timestamp
pub type DateTimePrecision {
YYYY
YYYYMM
YYYYMMDD
YYYYMMDDThhmmsszzzz
}
pub type DateTime {
DateTime(timestamp: timestamp.Timestamp, precision: DateTimePrecision)
}
pub fn parse_datetime (in: String) -> DateTime {
todo
}
pub fn main() {
echo timestamp.parse_rfc3339("2018")
echo timestamp.parse_rfc3339("1973-06")
echo timestamp.parse_rfc3339("1905-08-23")
echo timestamp.parse_rfc3339("2015-02-07T13:28:17-05:00")
echo timestamp.parse_rfc3339("2017-01-01T00:00:00.000Z")
}