TimeVal
extern type TimeVal = { tv_sec: i64, tv_usec: i64 }Fields
| Name | Type |
|---|---|
tv_sec | i64 |
tv_usec | i64 |
extern (C, header) fn Sleep(ms: u32) void = trust { ... } = "Sleep"extern type TimeVal = { tv_sec: i64, tv_usec: i64 }| Name | Type |
|---|---|
tv_sec | i64 |
tv_usec | i64 |
type DateTime = { year: mut i64, month: mut i64, day: mut i64, hour: mut i64, minute: mut i64, second: mut i64, millis: mut i64 }A DateTime holds a calendar date and wall-clock time.
| Name | Type |
|---|---|
year | mut i64 |
month | mut i64 |
day | mut i64 |
hour | mut i64 |
minute | mut i64 |
second | mut i64 |
millis | mut i64 |
pub fn (DateTime) new(year: i64, month: i64, day: i64, hour: i64, minute: i64, second: i64, millis: i64) DateTimeConstruct and return a new DateTime on the stack. All fields are validated on construction.
pub fn (DateTime) now() DateTimeReturn the current local time as a DateTime. Wraps the C localtime / gettimeofday pair.
pub fn unix_now() i64Return the current Unix timestamp in seconds since epoch.
pub fn unix_now_millis() i64Return the current Unix timestamp in milliseconds since epoch.
pub fn unix_now_micros() i64Return the current Unix timestamp in microseconds since epoch.
pub fn now_ns() i64Return the current Unix timestamp in nanoseconds since epoch. The time value is kept on the stack; no allocator is required.
pub fn sleep_millis(ms: i64) void = trust { ... }Sleep the current thread for approximately ms milliseconds.
pub fn (DateTime) year(dt: DateTime) i64Read the year field.
pub fn (DateTime) month(dt: DateTime) i64Read the month field (1–12).
pub fn (DateTime) day(dt: DateTime) i64Read the day field (1–31).
pub fn (DateTime) hour(dt: DateTime) i64Read the hour field (0–23).
pub fn (DateTime) minute(dt: DateTime) i64Read the minute field (0–59).
pub fn (DateTime) second(dt: DateTime) i64Read the second field (0–59).
pub fn (DateTime) millis(dt: DateTime) i64Read the milliseconds field (0–999).
pub fn (DateTime) to_unix(dt: DateTime) i64Convert a DateTime to a Unix timestamp (seconds since epoch). Does not account for leap seconds.
pub fn (DateTime) is_leap_year(dt: DateTime) boolReturn true if the year is a leap year.
pub fn (DateTime) days_in_month(dt: DateTime) i64Return the number of days in the month of this DateTime.
pub fn (DateTime) equals(a: DateTime, b: DateTime) boolReturn true if two DateTimes represent the same instant (ignoring millis).
pub fn (DateTime) before(a: DateTime, b: DateTime) boolReturn true if a is strictly before b.
pub fn (DateTime) after(a: DateTime, b: DateTime) boolReturn true if a is strictly after b.
pub fn (DateTime) diff_seconds(a: DateTime, b: DateTime) i64Return the difference in seconds between two DateTimes (a - b).