1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Port of `src/nvim/os/time.c` (not vendored under `vendor/`; the names appear as
//! calls in the vendored eval tree, so the drift gate recognizes them).
//!
//! Only the monotonic clock used by `profile.c`/`reltime()` is ported here.
use libc;
use ;
/// Port of `os_hrtime()` from `Src/os/time.c`.
///
/// "Gets a high-resolution (nanosecond), monotonically-increasing time
/// relative to an arbitrary time in the past." C delegates to `uv_hrtime()`,
/// which reads `CLOCK_MONOTONIC` (Linux) / mach time (macOS); `clock_gettime`
/// is the portable equivalent. Only differences are observable, so the
/// arbitrary epoch is immaterial.
/// Port of `os_localtime_r()` from `Src/os/time.c:108`.
///
/// Thread-safe broken-down local time. C threads the result through an out-param
/// `struct tm *` (here returned as `Option`, `None` on failure). C also calls
/// `tzset()` (cached) so a changed `$TZ` is honored; POSIX `localtime_r` already
/// does so internally, and the cache is only an optimization.
/// Port of `os_strptime()` from `Src/os/time.c:199`.
///
/// Parse `str` per `format` into `tm` (`strptime`); returns whether it parsed
/// (C returns the pointer past the last consumed char, or NULL — the caller only
/// tests for NULL). A NUL byte in either input makes the C string invalid, so it
/// is treated as a parse failure.