use std::fmt::Display; use std::fmt::Formatter; use std::time::Duration; use std::time::SystemTime; use anyhow::Context; use chrono::offset::Utc; use chrono::DateTime; use chrono::TimeZone; use sequoia_openpgp as openpgp; use openpgp::types::Timestamp; use crate::cli::SECONDS_IN_YEAR; use crate::cli::SECONDS_IN_DAY; use crate::Result; /// A signed offset (in seconds). #[derive(Debug, Clone, Eq, PartialEq)] pub struct Offset { /// Whether the offset is positive. positive: bool, /// The number of seconds. seconds: u64, } /// A thin wrapper around `openpgp::types::Timestamp`. /// /// Recall: an OpenPGP timestamp has a whole second resolution, and /// uses a 32-bit quantity to represent the number of seconds since /// the UNIX epoch. #[derive(Debug, Clone, Eq, PartialEq)] pub enum Time { Timestamp(Timestamp), Offset(Offset), } impl std::str::FromStr for Time { type Err = anyhow::Error; fn from_str(s: &str) -> anyhow::Result