Haka
time.h
Go to the documentation of this file.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
10 #ifndef HAKA_TIME_H
11 #define HAKA_TIME_H
12 
13 #include <haka/types.h>
14 
15 #include <time.h>
16 
17 
21 struct time {
22  time_t secs;
24 };
25 
26 #define TIME_BUFSIZE 27
27 #define INVALID_TIME { 0, 0 }
29 extern const struct time invalid_time;
30 
34 void time_build(struct time *t, double secs);
35 
39 bool time_gettimestamp(struct time *t);
40 
44 void time_add(struct time *res, const struct time *t1, const struct time *t2);
45 
50 int time_diff(struct time *res, const struct time *t1, const struct time *t2);
51 
55 uint64 time_divide(const struct time *t1, const struct time *t2);
56 
60 void time_mult(struct time *res, const struct time *t1, const int mult);
61 
66 int time_cmp(const struct time *t1, const struct time *t2);
67 
71 double time_sec(const struct time *t);
72 
77 bool time_tostring(const struct time *t, char *buffer, size_t len);
78 
83 bool time_format(const struct time *t, const char *format, char *buffer, size_t len);
84 
88 bool time_isvalid(const struct time *t);
89 
90 #endif /* HAKA_TIME_H */
uint64 time_divide(const struct time *t1, const struct time *t2)
Definition: time.c:75
uint32 nsecs
Definition: time.h:23
void time_mult(struct time *res, const struct time *t1, const int mult)
Definition: time.c:82
unsigned HAKA_64BIT_TYPE uint64
Definition: types.h:30
unsigned HAKA_32BIT_TYPE uint32
Definition: types.h:29
bool time_gettimestamp(struct time *t)
Definition: time.c:26
int time_cmp(const struct time *t1, const struct time *t2)
Definition: time.c:96
int time_diff(struct time *res, const struct time *t1, const struct time *t2)
Definition: time.c:63
bool time_format(const struct time *t, const char *format, char *buffer, size_t len)
Definition: time.c:131
double time_sec(const struct time *t)
Definition: time.c:91
Definition: time.h:21
time_t secs
Definition: time.h:22
void time_add(struct time *res, const struct time *t1, const struct time *t2)
Definition: time.c:39
bool time_tostring(const struct time *t, char *buffer, size_t len)
Definition: time.c:117
bool time_isvalid(const struct time *t)
Definition: time.c:146
void time_build(struct time *t, double secs)
Definition: time.c:20