gix_date/time/
mod.rs

1use crate::Time;
2
3/// Access
4impl Time {
5    /// Return true if this time has been initialized to anything non-default, i.e. 0.
6    pub fn is_set(&self) -> bool {
7        *self != Self::default()
8    }
9}
10
11/// Various ways to describe a time format.
12#[derive(Debug, Clone, Copy)]
13pub enum Format {
14    /// A custom format limited to what's in the [`format`](mod@format) submodule.
15    Custom(CustomFormat),
16    /// The seconds since 1970, also known as unix epoch, like `1660874655`.
17    Unix,
18    /// The seconds since 1970, followed by the offset, like `1660874655 +0800`
19    Raw,
20}
21
22/// A custom format for printing and parsing time.
23#[derive(Clone, Copy, Debug)]
24pub struct CustomFormat(pub(crate) &'static str);
25
26impl CustomFormat {
27    /// Create a new custom `format` suitable for use with the [`jiff`] crate.
28    pub const fn new(format: &'static str) -> Self {
29        Self(format)
30    }
31}
32
33impl From<CustomFormat> for Format {
34    fn from(custom_format: CustomFormat) -> Format {
35        Format::Custom(custom_format)
36    }
37}
38
39///
40pub mod format;
41mod init;
42mod write;