use anyhow::{Context, Result};
use time::format_description::well_known::Rfc3339;
use time::OffsetDateTime;
pub(crate) fn current_utc_rfc3339() -> Result<String> {
OffsetDateTime::now_utc()
.format(&Rfc3339)
.context("failed to format current UTC timestamp as RFC3339")
}
pub(crate) fn now_utc() -> OffsetDateTime {
OffsetDateTime::now_utc()
}
/// Parses an RFC3339 timestamp string. Returns `None` if the input does not
/// conform to RFC3339; callers decide how to handle unparseable values.
pub(crate) fn parse_rfc3339(s: &str) -> Option<OffsetDateTime> {
OffsetDateTime::parse(s, &Rfc3339).ok()
}