{0, 0, 0, 0}
};
+static void log_time_zone_info()
+{
+ time_t t = time(NULL);
+ struct tm tm = *localtime(&t);
+ fprintf(stderr, "Local time: %04d-%02d-%02d %02d:%02d:%02d. Time zone: %s (UTC",
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_zone);
+ char sign;
+ if (tm.tm_gmtoff >= 0) {
+ sign = '+';
+ }
+ else {
+ sign = '-';
+ tm.tm_gmtoff = -tm.tm_gmtoff;
+ }
+ int minutes = tm.tm_gmtoff / 60;
+ fprintf(stderr, "%c%02d%02d). ", sign, minutes / 60, minutes % 60);
+ fprintf(stderr, "Using UTC time in the log\n");
+}
+
+// et: epoch time; tm: UTC time (broken-down representation); millisec: milliseconds
static int get_current_time(time_t *et, struct tm *tm, int *millisec)
{
struct timeval timeval;
*et = t;
}
if (tm != NULL) {
- *tm = *localtime(&t);
+ *tm = *gmtime(&t);
}
*millisec = msec;
return result;
if (verbose) {
log_error("=== started ===");
+ log_time_zone_info();
int i;
for (i = 0; i < argc; i++) {
fprintf(stderr, "argv[%d] = %s\n", i, argv[i]);