Why doesn't Jiff support automatically parsing datetimes like 2025-03-10 02:00:59 -0500?
#356
-
|
Currently jiff can parse This format is e.g. described in --date=iso (or --date=iso8601) shows timestamps in a ISO 8601-like format. The differences to the strict ISO 8601 format are:
It is used by e.g. chrono and in GNU coreutils Also, while reading about the topic on Wikipedia I noticed that the Unicode minus ( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Thanks for the issue/question! So first and foremost, as documented, Jiff follows the Temporal ISO 8601 grammar. It is based on ISO 8601, but doesn't support all of it and does support some extensions that make it also compatible with RFC 3339 and RFC 9557. It's a hybrid format that's meant to cover most use cases. Jiff stays pretty strictly with what Temporal specifies. I'm very firmly opposed to expanding to beyond what Temporal supports because of negative second order effects. The format you ask about is not supported by Temporal's grammar. Secondly, Thirdly, it's not hard to use Jiff's use jiff::Timestamp;
fn main() -> anyhow::Result<()> {
let ts = Timestamp::strptime(
"%Y-%m-%d %H:%M:%S %z",
"2024-03-10 02:00:59 -0500",
)?;
assert_eq!(ts.to_string(), "2024-03-10T07:00:59Z");
Ok(())
}So from my perspective, yes, you don't get automatic parsing for free. But there is a very easy work-around if you need to support that specific format.
Yeah this is intentional. See tc39/ecma262#3334 and tc39/proposal-temporal#2856 |
Beta Was this translation helpful? Give feedback.
Thanks for the issue/question!
So first and foremost, as documented, Jiff follows the Temporal ISO 8601 grammar. It is based on ISO 8601, but doesn't support all of it and does support some extensions that make it also compatible with RFC 3339 and RFC 9557. It's a hybrid format that's meant to cover most use cases. Jiff stays pretty strictly with what Temporal specifies. I'm very firmly opposed to expanding to beyond what Temporal supports because of negative second order effects. The format you ask about is not supported by Temporal's grammar.
Secondly,
2024-03-10 02:00:59 -0500is not ISO 8601. It's not actually anything at all. It's not valid RFC 3339 or RFC 9557. I just double checked…