The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
time.h File Reference

clocks, sleeping and calendar time (UTC only: there are no time zones, so local time is UTC). More...

#include <sys/types.h>

Go to the source code of this file.

Data Structures

struct  timespec
struct  tm

Macros

#define NULL   ((void *)0)
#define CLOCK_REALTIME   0
#define CLOCK_MONOTONIC   1
#define CLOCK_PROCESS_CPUTIME_ID   2
#define CLOCKS_PER_SEC   1000000l
#define TIME_UTC   1

Typedefs

typedef int clockid_t

Functions

time_t time (time_t *out)
int clock_gettime (clockid_t id, struct timespec *out)
int timespec_get (struct timespec *out, int base)
 the time now (C11).
int clock_settime (clockid_t id, const struct timespec *when)
 set the realtime clock (root only; whole seconds)
int nanosleep (const struct timespec *span, struct timespec *left)
clock_t clock (void)
double difftime (time_t end, time_t start)
struct tm * gmtime_r (const time_t *t, struct tm *out)
struct tm * gmtime (const time_t *t)
struct tm * localtime_r (const time_t *t, struct tm *out)
struct tm * localtime (const time_t *t)
time_t timegm (struct tm *tm)
time_t mktime (struct tm *tm)
char * asctime_r (const struct tm *tm, char *buf)
char * asctime (const struct tm *tm)
char * ctime (const time_t *t)
size_t strftime (char *buf, size_t size, const char *format, const struct tm *tm)
 format a time.
char * strptime (const char *restrict text, const char *restrict format, struct tm *restrict tm)
 read a time from text as format says (the strftime conversions, and spaces in the format match any spaces) into the fields of tm it names.

Detailed Description

clocks, sleeping and calendar time (UTC only: there are no time zones, so local time is UTC).

struct timespec and the clock ids are ABI (src/kernel/time/clock.h).

Macro Definition Documentation

◆ NULL

#define NULL   ((void *)0)

◆ CLOCK_REALTIME

#define CLOCK_REALTIME   0

◆ CLOCK_MONOTONIC

#define CLOCK_MONOTONIC   1

◆ CLOCK_PROCESS_CPUTIME_ID

#define CLOCK_PROCESS_CPUTIME_ID   2

◆ CLOCKS_PER_SEC

#define CLOCKS_PER_SEC   1000000l

◆ TIME_UTC

#define TIME_UTC   1

Typedef Documentation

◆ clockid_t

typedef int clockid_t

Function Documentation

◆ time()

time_t time ( time_t * out)

◆ clock_gettime()

int clock_gettime ( clockid_t id,
struct timespec * out )

◆ timespec_get()

int timespec_get ( struct timespec * out,
int base )

the time now (C11).

Returns
base (TIME_UTC), or 0 for another base.

◆ clock_settime()

int clock_settime ( clockid_t id,
const struct timespec * when )

set the realtime clock (root only; whole seconds)

◆ nanosleep()

int nanosleep ( const struct timespec * span,
struct timespec * left )

◆ clock()

clock_t clock ( void )

◆ difftime()

double difftime ( time_t end,
time_t start )

◆ gmtime_r()

struct tm * gmtime_r ( const time_t * t,
struct tm * out )

◆ gmtime()

struct tm * gmtime ( const time_t * t)

◆ localtime_r()

struct tm * localtime_r ( const time_t * t,
struct tm * out )

◆ localtime()

struct tm * localtime ( const time_t * t)

◆ timegm()

time_t timegm ( struct tm * tm)

◆ mktime()

time_t mktime ( struct tm * tm)

◆ asctime_r()

char * asctime_r ( const struct tm * tm,
char * buf )

◆ asctime()

char * asctime ( const struct tm * tm)

◆ ctime()

char * ctime ( const time_t * t)

◆ strftime()

size_t strftime ( char * buf,
size_t size,
const char * format,
const struct tm * tm )

format a time.

supports a A b B c d e H I j m M n p S t u w y Y Z z F T D R and %%.

Returns
the length written, or 0 if it does not fit.

◆ strptime()

char * strptime ( const char *restrict text,
const char *restrict format,
struct tm *restrict tm )

read a time from text as format says (the strftime conversions, and spaces in the format match any spaces) into the fields of tm it names.

Returns
the first character not read, or NULL when the text does not fit.