9 #ifndef __libutilxx__sella__util__Time_H__
10 #define __libutilxx__sella__util__Time_H__
12 #include "../../common.h"
29 static struct timeval htontv(const struct timeval &src)
throw ();
30 static struct timeval ntohtv(const struct timeval &src)
throw ();
31 static void cleartv(
struct timeval &src)
throw ();
32 static int comparetv(
const struct timeval &a,
const struct timeval &b)
throw ();
33 static struct timeval& copytv(
struct timeval &dst,
const struct timeval &src)
throw ();
34 static struct timeval& subtracttv(
struct timeval &dst,
const struct timeval &src)
throw ();
35 static struct timeval& addtv(
struct timeval &dst,
const struct timeval &src)
throw ();
37 static struct timespec htonts(const struct timespec &ts)
throw ();
38 static struct timespec ntohts(const struct timespec &ts)
throw ();
40 static void clearts(
struct timespec &ts)
throw ();
41 static int comparets(
const struct timespec &a,
const struct timespec &b)
throw ();
42 static struct timespec& copyts(
struct timespec &dst,
const struct timespec &src)
throw ();
43 static struct timespec& subtractts(
struct timespec &dst,
const struct timespec &src)
throw ();
44 static struct timespec& addts(
struct timespec &dst,
const struct timespec &src)
throw ();
46 static struct timespec clock_realtime() throw ();
47 static struct timespec clock_realtime_coarse() throw ();
48 static struct timespec clock_monotonic() throw ();
49 static struct timespec clock_monotonic_coarse() throw ();
50 static struct timespec clock_monotonic_raw() throw ();
51 static struct timespec clock_boottime() throw ();
52 static struct timespec clock_process_cputime_id() throw ();
53 static struct timespec clock_thread_cputime_id() throw ();
54 static uint64_t tstousec(
const struct timespec &ts)
throw ();
55 static uint64_t tstomsec(
const struct timespec &ts)
throw ();
56 static uint64_t tstosec(
const struct timespec &ts)
throw ();
57 static struct timespec sectots(uint64_t sec) throw ();
58 static struct timespec msectots(uint64_t msec) throw ();
59 static struct timespec usectots(uint64_t usec) throw ();
61 static std::string tmtostr(
const struct tm &tm,
const char* format =
"%a %Y-%m-%d %H:%M:%S %Z")
throw ();
62 static std::string tstostr(
const struct timespec &ts,
const char* format =
"%a %Y-%m-%d %H:%M:%S %Z")
throw ();
63 static std::string sectostr(uint64_t sec = 0,
const char* format =
"%a %Y-%m-%d %H:%M:%S %Z")
throw ();
64 static std::string usectostr(uint64_t usec = 0,
const char* format =
"%a %Y-%m-%d %H:%M:%S %Z")
throw ();
65 static std::string msectostr(uint64_t msec = 0,
const char* format =
"%a %Y-%m-%d %H:%M:%S %Z")
throw ();
67 static struct timeval gettimeofday(struct timezone *tz = NULL)
throw ();
68 static uint64_t gettimeofday_usec(
struct timezone *tz = NULL)
throw ();
69 static uint64_t gettimeofday_msec(
struct timezone *tz = NULL)
throw ();
70 static uint64_t gettimeofday_sec(
struct timezone *tz = NULL)
throw ();
71 static uint64_t tvtousec(
const struct timeval &tv)
throw ();
72 static uint64_t tvtomsec(
const struct timeval &tv)
throw ();
73 static uint64_t tvtosec(
const struct timeval &tv)
throw ();
74 static struct timeval chronototv(const std::chrono::system_clock::duration &duration) throw ();
75 static struct timeval chronototv(const std::chrono::system_clock::time_point &tp) throw ();
76 static struct timeval sectotv(uint64_t sec) throw ();
77 static struct timeval usectotv(uint64_t usec) throw ();
78 static struct timeval msectotv(uint64_t msec) throw ();
79 static struct timeval* add_usectotv(struct timeval &tv, const uint64_t usec) throw ();
80 static struct timeval* add_msectotv(struct timeval &tv, const uint64_t msec) throw ();
81 static struct timeval* add_sectotv(struct timeval &tv, const uint64_t sec) throw ();
83 static std::string getRFC1123Date(void) throw ();