2023-07-16 23:56:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
struct Time {
|
|
|
|
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)
|
|
|
|
};
|
|
|
|
|
2023-07-17 23:34:52 +00:00
|
|
|
enum Timezone {
|
|
|
|
UTC = 0,
|
|
|
|
EST = -4
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the current timezone
|
|
|
|
*/
|
|
|
|
extern void set_timezone(enum Timezone tz);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns current time in UTC
|
|
|
|
*/
|
|
|
|
extern struct Time get_utctime(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns current time from current Timezone
|
|
|
|
*/
|
|
|
|
extern struct Time get_localtime(void);
|
2023-07-16 23:56:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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(struct Time *time, char *format, char *buf, size_t n);
|