24#if GETTIMEOFDAY_NO_TZP
39 return (t2.tv_sec - t1.tv_sec) * 1000000 +
40 (t2.tv_usec - t1.tv_usec);
46 return (
double) (t2.tv_sec - t1.tv_sec) +
47 (
double) (t2.tv_usec - t1.tv_usec) / 1000000.0;
53 return (t2.tv_sec - t1.tv_sec) * 1000 +
54 (t2.tv_usec - t1.tv_usec) / 1000;
58tvSub(
struct timeval &res,
struct timeval
const &t1,
struct timeval
const &t2)
60 res.tv_sec = t2.tv_sec - t1.tv_sec;
61 if (t2.tv_usec >= t1.tv_usec)
62 res.tv_usec = t2.tv_usec - t1.tv_usec;
65 res.tv_usec = t2.tv_usec + 1000000 - t1.tv_usec;
69void tvAdd(
struct timeval &res,
struct timeval
const &t1,
struct timeval
const &t2)
71 res.tv_sec = t1.tv_sec + t2.tv_sec;
72 res.tv_usec = t1.tv_usec + t2.tv_usec;
73 if (res.tv_usec >= 1000000) {
75 res.tv_usec -= 1000000;
81 t.tv_sec += add.tv_sec;
82 t.tv_usec += add.tv_usec;
83 if (t.tv_usec >= 1000000) {
92 os << t.tv_sec <<
".";
93 const auto savedFill = os.fill(
'0');
94 os << std::setw(6) << t.tv_usec;
103 static char buf[128];
104 static time_t last_t = 0;
108 strftime(buf, 127,
"%Y/%m/%d %H:%M:%S", tm);
118 static char buf[128];
119 static time_t last_t = 0;
122 struct tm *gmt = gmtime(&t);
125 int gmt_min, gmt_hour, gmt_yday, day_offset;
131 gmt_min = gmt->tm_min;
132 gmt_hour = gmt->tm_hour;
133 gmt_yday = gmt->tm_yday;
137 day_offset = lt->tm_yday - gmt_yday;
141 else if (day_offset < -1)
144 min_offset = day_offset * 1440 + (lt->tm_hour - gmt_hour) * 60
145 + (lt->tm_min - gmt_min);
147 len = strftime(buf, 127 - 5,
"%d/%b/%Y:%H:%M:%S ", lt);
148 snprintf(buf + len, 128 - len,
"%+03d%02d",
149 (min_offset / 60) % 24,
153 strftime(buf, 127,
"%d/%b/%Y:%H:%M:%S -000", gmt);
const char * FormatStrf(time_t)
const char * FormatHttpd(time_t)
void tvAdd(struct timeval &res, struct timeval const &t1, struct timeval const &t2)
time_t squid_curtime
the current UNIX time in seconds
double tvSubDsec(struct timeval t1, struct timeval t2)
void tvSub(struct timeval &res, struct timeval const &t1, struct timeval const &t2)
std::ostream & operator<<(std::ostream &os, const timeval &t)
prints <seconds>.<microseconds>
int tvSubUsec(struct timeval t1, struct timeval t2)
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
double current_dtime
the current UNIX time in seconds (with microsecond precision)
void tvAssignAdd(struct timeval &t, struct timeval const &add)
int tvSubMsec(struct timeval t1, struct timeval t2)