Usermode/libc - C++ wrapping in headers, time rework
[tpg/acess2.git] / Usermode / Libraries / libc.so_src / include_exp / time.h
1 /*
2  * Acess2 C Library
3  * - By John Hodge (thePowersGang)
4  *
5  * time.h
6  * - C99 Time Functions
7  */
8 #ifndef _TIME_H_
9 #define _TIME_H_
10
11 #include <sys/types.h>  // time_t
12 #include <stddef.h>     // size_t
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 struct tm
19 {
20          int    tm_sec; // 0-60
21          int    tm_min; // 0-59
22          int    tm_hour;
23          int    tm_mday;
24          int    tm_mon;
25          int    tm_year;        // 1900 based
26          int    tm_wday;
27          int    tm_yday;
28          int    tm_isdst;
29 };
30
31 #define CLOCKS_PER_SEC  1000
32
33 typedef signed long long        clock_t;
34
35 //! Processor time used since invocation
36 extern clock_t  clock(void);
37
38 //! Difference between two times in seconds
39 extern double difftime(time_t time1, time_t time0);
40
41 //! Convert a local time into the format returned by \a time
42 //! \note Also updates tm_wday and tm_yday to the correct values
43 extern time_t   mktime(struct tm *timeptr);
44
45 //! Get the current calendar time
46 //! \note -1 is returned if the calendar time is not avaliable
47 extern time_t   time(time_t *t);
48
49 //
50 // Time conversions
51 //
52 //! Convert the time structure into a string of form 'Sun Sep 16 01:03:52 1973\n\0'
53 extern char *asctime(const struct tm *timeptr);
54 extern char *asctime_r(const struct tm *timeptr, char *buf);
55
56 //! asctime(localtime(timer))
57 extern char *ctime(const time_t *timer);
58 extern char *ctime_r(const time_t *timer, struct tm *result);
59
60 //! Convert \a timter into UTC
61 extern struct tm *gmtime(const time_t *timer);
62 extern struct tm *gmtime_r(const time_t *timer, struct tm *result);
63
64 extern struct tm *localtime(const time_t *timer);
65 extern struct tm *localtime_r(const time_t *timep, struct tm *result);
66
67 extern size_t strftime(char*s, size_t maxsize, const char*format, const struct tm*timeptr);
68
69 #ifdef __cplusplus
70 };
71 #endif
72
73 #include <libposix_time.h>
74
75 #endif
76

UCC git Repository :: git.ucc.asn.au