Eris Linux A.P.I. 0.1
API to access Eris Linux system from a custom container
Loading...
Searching...
No Matches
TIME

Time and timezone related functions. More...

Functions

int eris_get_ntp_server (char *buffer, size_t size)
 Get the current NTP server used by the machine.
int eris_set_ntp_server (const char *server)
 Set the NTP server to use by the machine.
int eris_get_ntp_enable (char *buffer, size_t size)
 Get the current NTP status.
int eris_set_ntp_enable (const char *status)
 Set the NTP status.
int eris_list_time_zones (char *buffer, size_t size)
 List the timezones known by the system.
int eris_get_time_zone (char *buffer, size_t size)
 Get the current timezone of the system.
int eris_set_time_zone (const char *timezone)
 Set the system timezone.
int eris_get_local_time (char *buffer, size_t size)
 Get the local time.
int eris_get_system_time (char *buffer, size_t size)
 Get the system time.
int eris_set_system_time (const char *time)
 Set the system time.

Detailed Description

Time and timezone related functions.

Function Documentation

◆ eris_get_local_time()

int eris_get_local_time ( char * buffer,
size_t size )

Get the local time.

This function fills the provided buffer with the local time.

The local time is computed using the timezone of the system.

The format for local time is YYYY-MM-DD hh:mm:ss:uuuuuu (uuuuuu represents microseconds).

Parameters
bufferthe buffer to fill.
sizethe size of the buffer.

The buffer zie must be at least 27 bytes.

Returns
0 on success, -1 on error and errno is set appropriately.

◆ eris_get_ntp_enable()

int eris_get_ntp_enable ( char * buffer,
size_t size )

Get the current NTP status.

This functions fills the provided buffer with the string yes or no depending whether the NTP usage is currently enabled or disabled.

Parameters
bufferthe buffer to fill with the NTP status.
sizethe size of the buffer.
Returns
0 on success, -1 on error and errno is set appropriately.

◆ eris_get_ntp_server()

int eris_get_ntp_server ( char * buffer,
size_t size )

Get the current NTP server used by the machine.

This function fills the provided buffer with the current NTP server.

Parameters
bufferthe buffer to fill with the server adress or name.
sizethe size of the buffer.
Returns
0 on success, -1 on error and errno is set appropriately.

A NTP (Network Time Protocol) server is a machine with a precise time keeping source (GPS, atomic clock, etc.). This server is configured to answer other machine's requests to setup their own system clock.

There are many NTP servers on Internet. The one used by default by Eris is pool.ntp.org, but you can prefer your own server (maybe on a local network, or totaly disable the NTP use.

◆ eris_get_system_time()

int eris_get_system_time ( char * buffer,
size_t size )

Get the system time.

This function fills the provided buffer with the system time (i.e. the current time in UTC timezone).

The system clock is configured (using NTP for example) and maintained in UTC (Universal Time Coordinate) timezone.

The format for system time is YYYY-MM-DD hh:mm:ss:uuuuuu (uuuuuu represents microseconds).

Parameters
bufferthe buffer to fill.
sizethe size of the buffer.

The buffer zie must be at least 27 bytes.

Returns
0 on success, -1 on error and errno is set appropriately.

◆ eris_get_time_zone()

int eris_get_time_zone ( char * buffer,
size_t size )

Get the current timezone of the system.

This function fills the provided buffer with the name of the timezone used to display local time.

Parameters
bufferthe buffer to fill with the timezone name
sizethe size of the buffer.
Returns
0 on success, -1 on error and errno is set appropriately.

◆ eris_list_time_zones()

int eris_list_time_zones ( char * buffer,
size_t size )

List the timezones known by the system.

This function fills the provided buffer with the list of all timezones available.

Parameters
bufferthe buffer to fill with the list of timezone.
sizethe size of the buffer.

The recommanded size of the buffer is about 10kbytes.

Returns
0 on success, -1 on error and errno is set appropriately.

◆ eris_set_ntp_enable()

int eris_set_ntp_enable ( const char * status)

Set the NTP status.

This function stores the NTP status (yes or no) to enable or disable NTP usage.

Parameters
statusyes or no.
Returns
0 on success, -1 on error and errno is set appropriately.

◆ eris_set_ntp_server()

int eris_set_ntp_server ( const char * server)

Set the NTP server to use by the machine.

This function stores the given NTP server in Eris system.

Parameters
serverthe hostname or the IP address of the NTP server.
Returns
0 on success, -1 on error and errno is set appropriately.

◆ eris_set_system_time()

int eris_set_system_time ( const char * time)

Set the system time.

This function sets the system clock with the (UTC timezone) time provided in the buffer.

The format for system time may be:

  • YYYY-MM-DDThh:mm:ss
  • YYYY-MM-DD hh:mm:ss
  • YYYY/MM/DD hh:mm:ss
  • YYYY:MM:DD:hh:mm:ss
Parameters
timethe system time.
Returns
0 on success, -1 on error and errno is set appropriately.

◆ eris_set_time_zone()

int eris_set_time_zone ( const char * timezone)

Set the system timezone.

This function stores the name of the timezone to use when computing local time.

The name must be in the list returned by eris_list_time_zones().

Parameters
timezonethe name of the timezone.
Returns
0 on success, -1 on error and errno is set appropriately.