blob: 2e86a6951a92ce4272a69da7e7e5856f234d3ca9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#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);
/**
* 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);
|