Search results

There are no results.

std.fs.Time

Value
type pub copy Time

A 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: Int

The seconds of the timestamp.

nanos

let pub @nanos: Int

The nanoseconds after the second of the timestamp.

Instance methods

to_date_time

Show source code
Hide source code
fn pub to_date_time -> DateTime {
  DateTime.from_timestamp(to_secs, utc_offset: 0).get
}
fn pub to_date_time -> DateTime

Converts 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 code
Hide source code
fn pub to_nanos -> Int {
  @secs * 1_000_000_000 + @nanos
}
fn pub to_nanos -> Int

Returns 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 code
Hide source code
fn pub to_secs -> Float {
  @secs.to_float + (@nanos.to_float / 1_000_000_000.0)
}
fn pub to_secs -> Float

Returns the timestamp as the seconds and sub seconds since the epoch.