Functions
time.c File Reference
#include <assert.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include <limits.h>
#include <uv.h>
#include "nvim/os/input.h"
#include "nvim/event/loop.h"
#include "nvim/vim.h"
#include "nvim/main.h"

Functions

void time_init (void)
 Initializes the time module. More...
 
uint64_t os_hrtime (void)
 
uint64_t os_now (void)
 
void os_delay (uint64_t ms, bool ignoreinput)
 
void os_microdelay (uint64_t us, bool ignoreinput)
 
struct tm * os_localtime_r (const time_t *restrict clock, struct tm *restrict result) FUNC_ATTR_NONNULL_ALL
 
struct tm * os_localtime (struct tm *result) FUNC_ATTR_NONNULL_ALL
 
Timestamp os_time (void)
 

Function Documentation

void os_delay ( uint64_t  ms,
bool  ignoreinput 
)

Sleeps for ms milliseconds.

Parameters
msNumber of milliseconds to sleep
ignoreinputIf true, only SIGINT (CTRL-C) can interrupt.
uint64_t os_hrtime ( void  )

Gets a high-resolution (nanosecond), monotonically-increasing time relative to an arbitrary time in the past.

Not related to the time of day and therefore not subject to clock drift.

Returns
Relative time value with nanosecond precision.
struct tm* os_localtime ( struct tm *  result)

Gets the current Unix timestamp and adjusts it to local time.

Parameters
resultPointer to a 'struct tm' where the result should be placed
Returns
A pointer to a 'struct tm' in the current time zone (the 'result' argument) or NULL in case of error
struct tm* os_localtime_r ( const time_t *restrict  clock,
struct tm *restrict  result 
)

Portable version of POSIX localtime_r()

Returns
NULL in case of error
void os_microdelay ( uint64_t  us,
bool  ignoreinput 
)

Sleeps for us microseconds.

Parameters
usNumber of microseconds to sleep.
ignoreinputIf true, ignore all input (including SIGINT/CTRL-C). If false, waiting is aborted on any input.
uint64_t os_now ( void  )

Gets a millisecond-resolution, monotonically-increasing time relative to an arbitrary time in the past.

Not related to the time of day and therefore not subject to clock drift. The value is cached by the loop, it will not change until the next loop-tick (unless uv_update_time is called).

Returns
Relative time value with millisecond precision.
Timestamp os_time ( void  )

Obtains the current Unix timestamp.

Returns
Seconds since epoch.
void time_init ( void  )

Initializes the time module.