gix_date/
lib.rs

1//! Date and time parsing similar to what git can do.
2//!
3//! Note that this is not a general purpose time library.
4//! ## Feature Flags
5#![cfg_attr(
6    all(doc, feature = "document-features"),
7    doc = ::document_features::document_features!()
8)]
9#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg))]
10#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
11///
12pub mod time;
13
14///
15pub mod parse;
16pub use parse::function::{parse, parse_header};
17
18pub use gix_error::ParseError as Error;
19
20/// A timestamp with timezone.
21#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
22#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
23pub struct Time {
24    /// The seconds that have passed since UNIX epoch. This makes it UTC, or `<seconds>+0000`.
25    pub seconds: SecondsSinceUnixEpoch,
26    /// The time's offset in seconds, which may be negative to match the `sign` field.
27    pub offset: OffsetInSeconds,
28}
29
30/// The number of seconds since unix epoch.
31///
32/// Note that negative dates represent times before the unix epoch.
33///
34/// ### Deviation
35///
36/// `git` only supports dates *from* the UNIX epoch, whereas we chose to be more flexible at the expense of stopping time
37/// a few million years before the heat-death of the universe.
38pub type SecondsSinceUnixEpoch = i64;
39/// time offset in seconds.
40pub type OffsetInSeconds = i32;