diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-04 00:10:16 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-04 00:10:16 -0400 |
commit | 3a44b8da250ffafec26a1c61cf41eeb5978f4549 (patch) | |
tree | 809bec6f8dd8a953d27708bf27d99e551997138e /include/time.h | |
parent | serial and tty (diff) | |
download | comus-3a44b8da250ffafec26a1c61cf41eeb5978f4549.tar.gz comus-3a44b8da250ffafec26a1c61cf41eeb5978f4549.tar.bz2 comus-3a44b8da250ffafec26a1c61cf41eeb5978f4549.zip |
real time clock
Diffstat (limited to 'include/time.h')
-rw-r--r-- | include/time.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/time.h b/include/time.h new file mode 100644 index 0000000..b3b0fc1 --- /dev/null +++ b/include/time.h @@ -0,0 +1,63 @@ +/** + * @file time.h + * + * @author Freya Murphy <freya@freyacat.org> + * + * System time structure + */ + +#ifndef TIME_H_ +#define TIME_H_ + +#include <stddef.h> + +typedef struct { + int sec; /// Seconds [0,59] + int min; /// Minutes [0,59] + int hour; /// Hour [0,23] + int mday; /// Day of month [1,31] + int mon; /// Month of year [0,11] + int year; /// Years since 1900 + int wday; /// Day of week [0,6] (Sunday = 0) + int yday; /// Day of year [0,365] + int yn; /// Year number [0,99] + int cen; /// Century [19,20] + int leap; /// If year is a leap year (True == 1) +} time_t; + +typedef enum { + TZ_UTC = 0, + TZ_EST = -5, + TZ_EDT = -4, +} timezone_t; + +/** + * Sets the current timezone + */ +extern void set_timezone(timezone_t tz); + +/** + * Returns current time in UTC + */ +extern time_t get_utctime(void); + +/** + * Returns current time from current Timezone + */ +extern time_t get_localtime(void); + +/** + * Return the time on the system clock + */ +extern size_t get_systemtime(void); + +/** + * Converts the time into a string format + * + * @param time - the current time + * @param format - see manpage for date + * @param buf - the buffer to store it in + */ +extern void timetostr(time_t *time, char *format, char *buf, size_t n); + +#endif /* time.h */ |