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, doc_auto_cfg))]
10#![deny(missing_docs, rust_2018_idioms)]
11#![forbid(unsafe_code)]
12
13///
14pub mod time;
15
16///
17pub mod parse;
18pub use parse::function::parse;
19
20/// A timestamp with timezone.
21#[derive(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 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 /// the sign of `offset`, used to encode `-0000` which would otherwise lose sign information.
29 pub sign: time::Sign,
30}
31
32/// The amount of seconds since unix epoch.
33///
34/// Note that negative dates represent times before the unix epoch.
35///
36/// ### Deviation
37///
38/// `git` only supports dates *from* the UNIX epoch, whereas we chose to be more flexible at the expense of stopping time
39/// a few million years before the heat-death of the universe.
40pub type SecondsSinceUnixEpoch = i64;
41/// time offset in seconds.
42pub type OffsetInSeconds = i32;