pub struct GitTime {
pub seconds: i64,
pub timezone_offset_minutes: i16,
pub negative_utc: bool,
}Expand description
A git timestamp: a Unix time plus the committer’s timezone offset.
The offset is stored as signed minutes east of UTC (timezone_offset_minutes)
and a separate negative_utc flag. The flag exists because git
distinguishes the timezone token -0000 from +0000: both are zero minutes
from UTC, but git writes -0000 as a sentinel meaning “timezone unknown”
(e.g. for dates parsed without zone information), and that distinction is
part of a commit’s byte-exact identity. timezone_offset_minutes alone
cannot represent it, so negative_utc carries the sign of a zero offset.
Fields§
§seconds: i64Seconds since the Unix epoch.
timezone_offset_minutes: i16Timezone offset east of UTC, in minutes (e.g. +0530 -> 330,
-0500 -> -300). Zero for both +0000 and -0000; consult
GitTime::negative_utc to tell those apart.
negative_utc: booltrue only when the timezone token had a negative sign with a zero
magnitude (-0000), git’s “timezone unknown” sentinel. Always false
for any non-zero offset.
Implementations§
Source§impl GitTime
impl GitTime
Sourcepub const fn new(seconds: i64, timezone_offset_minutes: i16) -> Self
pub const fn new(seconds: i64, timezone_offset_minutes: i16) -> Self
A GitTime with the given seconds and minute offset, treating a zero
offset as the ordinary +0000 (not the -0000 sentinel). Use
GitTime::with_negative_utc to construct the -0000 case.
Sourcepub const fn with_negative_utc(seconds: i64) -> Self
pub const fn with_negative_utc(seconds: i64) -> Self
A GitTime whose timezone is the -0000 sentinel (“timezone unknown”).
The minute offset is zero; negative_utc is true.
Sourcepub fn offset_token(self) -> String
pub fn offset_token(self) -> String
The canonical 5-character timezone token for this offset (sign plus four
digits), e.g. +0000, -0500, +0530. Returns -0000 when
GitTime::negative_utc is set.