finix/kernel/include/time.h
2023-07-22 11:05:30 -04:00

51 lines
1.1 KiB
C

#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)
};
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);
/**
* 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(struct Time *time, char *format, char *buf, size_t n);