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
18/// A timestamp with timezone.
19#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
20#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
21pub struct Time {
22 /// The seconds that have passed since UNIX epoch. This makes it UTC, or `<seconds>+0000`.
23 pub seconds: SecondsSinceUnixEpoch,
24 /// The time's offset in seconds, which may be negative to match the `sign` field.
25 pub offset: OffsetInSeconds,
26}
27
28/// The number of seconds since unix epoch.
29///
30/// Note that negative dates represent times before the unix epoch.
31///
32/// ### Deviation
33///
34/// `git` only supports dates *from* the UNIX epoch, whereas we chose to be more flexible at the expense of stopping time
35/// a few million years before the heat-death of the universe.
36pub type SecondsSinceUnixEpoch = i64;
37/// time offset in seconds.
38pub type OffsetInSeconds = i32;