Expand description
Date and time parsing similar to what git can do.
Note that this is not a general purpose time library.
§Examples
use gix_date::{
parse,
parse_header,
time::{format, Format},
};
let time = parse("Thu, 18 Aug 2022 12:45:06 +0800", None).unwrap();
assert_eq!(time.offset, 8 * 60 * 60);
assert_eq!(time.format(Format::Raw).unwrap(), "1660797906 +0800");
assert_eq!(time.format(Format::Custom(format::ISO8601)).unwrap(), "2022-08-18 12:45:06 +0800");
let from_header = parse_header("1660797906 +0800").unwrap();
assert_eq!(from_header, time);§Feature Flags
serde— Data structures implementserde::Serializeandserde::Deserialize.
Modules§
Structs§
Functions§
- parse
- Parse
inputas any time that Git can parse when inputting a date. - parse_
header - Unlike
parse()which handles all kinds of input, this function only parses the commit-header format like1745582210 +0200.
Type Aliases§
- Offset
InSeconds - time offset in seconds.
- Seconds
Since Unix Epoch - The number of seconds since unix epoch.