std.fs.Time
Valuetype pub copy TimeA file timestamp expressed as a number of seconds and nanoseconds.
The seconds and nanoseconds are stored separately to ensure no loss of
precision, something that might happen when storing the time as a Float.
Fields
secs
let pub @secs: IntThe seconds of the timestamp.
nanos
let pub @nanos: IntThe nanoseconds after the second of the timestamp.
Instance methods
to_date_time
Show source codeHide source code
fn pub to_date_time -> DateTime {
DateTime.from_timestamp(to_secs, utc_offset: 0).get
}fn pub to_date_time -> DateTimeConverts self into a DateTime.
The returned DateTime uses UTC as its offset.
Panics
This method may panic if the time can't be expressed in a DateTime. This
can only happen if the system clock is returning nonsensical values (e.g. a
year outside of the 32-bits signed integer range).
to_nanos
Show source codeHide source code
fn pub to_nanos -> Int {
@secs * 1_000_000_000 + @nanos
}fn pub to_nanos -> IntReturns the timestamp as the nanoseconds since the epoch.
Panics
If the time is more than 292 years in the future or in the past relative to the epoch, this method may panic.
to_secs
Show source codeHide source code
fn pub to_secs -> Float {
@secs.to_float + (@nanos.to_float / 1_000_000_000.0)
}fn pub to_secs -> FloatReturns the timestamp as the seconds and sub seconds since the epoch.