]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/SquidTime.h
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 21 Time Functions */
17 /* NP: sys/time.h is provided by libcompat */
19 /* Use uint64_t to store milliseconds */
20 typedef uint64_t time_msec_t
;
22 /* globals for accessing time */
23 extern struct timeval current_time
;
24 extern double current_dtime
;
25 extern time_t squid_curtime
;
27 time_t getCurrentTime(void);
28 int tvSubMsec(struct timeval
, struct timeval
);
30 /// timeval substraction operation
31 /// \param[out] res = t2 - t1
32 void tvSub(struct timeval
&res
, struct timeval
const &t1
, struct timeval
const &t2
);
34 /// timeval addition operation
35 /// \param[out] res = t1 + t2
36 void tvAdd(struct timeval
&res
, struct timeval
const &t1
, struct timeval
const &t2
);
38 /// timeval addition assignment operation
39 /// \param[out] t += add
40 void tvAssignAdd(struct timeval
&t
, struct timeval
const &add
);
42 /// Convert timeval to milliseconds
43 inline long int tvToMsec(struct timeval
&t
)
45 return t
.tv_sec
* 1000 + t
.tv_usec
/ 1000;
48 /** event class for doing synthetic time etc */
53 virtual ~TimeEngine();
55 /** tick the clock - update from the OS or other time source, */
62 /** Display time as a formatted human-readable string.
64 * "YYYY/MM/DD hh:mm:ss"
66 * Output is only valid until next call to this function.
68 const char *FormatStrf(time_t t
);
70 /** Display time as a formatted human-readable string.
71 * Time string syntax used is that of Apache httpd.
72 * "DD/MMM/YYYY:hh:mm:ss zzzz"
74 * Output is only valid until next call to this function.
76 const char *FormatHttpd(time_t t
);
80 #endif /* SQUID_TIME_H */