libnotcurses_sys/
time.rs

1//! `NcTime`
2
3use crate::c_api::ffi::timespec;
4
5#[cfg(not(feature = "libc"))]
6use crate::c_api::ffi::{__syscall_slong_t as c_long, __time_t as time_t};
7
8// needed for MacOs
9#[cfg(feature = "libc")]
10use libc::{c_long, time_t};
11
12/// A time in seconds and nanoseconds.
13///
14/// It assumes that pre-epoch Timespecs have negative `tv_sec` and positive nsec fields.
15///
16/// A record specifying a time value in seconds and nanoseconds, where
17/// nanoseconds represent the offset from the given second.
18// Expected by [`notcurses_get`] & [`notcurses_get_nblock`].
19pub type NcTime = timespec;
20
21impl NcTime {
22    /// New `NcTime` with the specified seconds and nanoseconds.
23    pub fn new(seconds: time_t, nanoseconds: c_long) -> Self {
24        Self { tv_sec: seconds, tv_nsec: nanoseconds }
25    }
26}