objc

date.h
Go to the documentation of this file.
1 
29 #pragma once
30 #include <stdbool.h>
31 #include <stdint.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
45 typedef struct sys_date_t {
46  int64_t seconds;
47  int32_t nanoseconds;
48  int32_t tzoffset;
49 } sys_date_t;
51 
59 bool sys_date_get_now(sys_date_t *date);
60 
74 bool sys_date_set_now(const sys_date_t *date);
75 
90 bool sys_date_get_time_utc(sys_date_t *date, uint8_t *hours, uint8_t *minutes,
91  uint8_t *seconds);
92 
107 bool sys_date_get_time_local(sys_date_t *date, uint8_t *hours, uint8_t *minutes,
108  uint8_t *seconds);
109 
126 bool sys_date_get_date_utc(sys_date_t *date, uint16_t *year, uint8_t *month,
127  uint8_t *day, uint8_t *weekday);
128 
145 bool sys_date_get_date_local(sys_date_t *date, uint16_t *year, uint8_t *month,
146  uint8_t *day, uint8_t *weekday);
147 
162 bool sys_date_set_time_utc(sys_date_t *date, uint8_t hours, uint8_t minutes,
163  uint8_t seconds);
164 
179 bool sys_date_set_date_utc(sys_date_t *date, uint16_t year, uint8_t month,
180  uint8_t day);
181 
192 int64_t sys_date_compare_ns(const sys_date_t *start, const sys_date_t *end);
193 
201 uint64_t sys_date_get_timestamp();
202 
203 #ifdef __cplusplus
204 }
205 #endif
bool sys_date_get_date_utc(sys_date_t *date, uint16_t *year, uint8_t *month, uint8_t *day, uint8_t *weekday)
Extracts date components from a sys_date_t structure.
int64_t sys_date_compare_ns(const sys_date_t *start, const sys_date_t *end)
Calculate the difference in nanoseconds between two sys_date_t structures.
bool sys_date_get_date_local(sys_date_t *date, uint16_t *year, uint8_t *month, uint8_t *day, uint8_t *weekday)
Extracts date components from a sys_date_t structure.
int64_t seconds
Seconds since Unix epoch (January 1, 1970 00:00:00 UTC)
Definition: date.h:46
struct sys_date_t sys_date_t
Represents a system date and time structure.
bool sys_date_set_time_utc(sys_date_t *date, uint8_t hours, uint8_t minutes, uint8_t seconds)
Sets time components in a sys_date_t structure, preserving the date and timezone offset.
int32_t nanoseconds
Fractional seconds in nanoseconds (0-999999999)
Definition: date.h:47
bool sys_date_set_date_utc(sys_date_t *date, uint16_t year, uint8_t month, uint8_t day)
Sets date components in a sys_date_t structure, preserving the time and timezone offset.
bool sys_date_set_now(const sys_date_t *date)
Sets the current system time.
bool sys_date_get_time_utc(sys_date_t *date, uint8_t *hours, uint8_t *minutes, uint8_t *seconds)
Extracts time components from a sys_date_t structure.
int32_t tzoffset
Timezone offset in seconds from UTC (positive = east of UTC)
Definition: date.h:48
bool sys_date_get_time_local(sys_date_t *date, uint8_t *hours, uint8_t *minutes, uint8_t *seconds)
Extracts time components from a sys_date_t structure.
Represents a system date and time structure.
Definition: date.h:45
bool sys_date_get_now(sys_date_t *date)
Gets the current system time.
uint64_t sys_date_get_timestamp()
Gets the number of milliseconds since the process started.