read_cifs_stat(curr);
/* Get time */
- get_localtime(rectime, 0);
+ get_xtime(rectime, 0, LOCAL_TIME);
/* Print results */
write_stats(curr, rectime);
/* How many processors on this machine? */
cpu_nr = get_cpu_nr(~0, FALSE);
- get_localtime(&rectime, 0);
+ get_xtime(&rectime, 0, LOCAL_TIME);
/*
* Don't buffer data if redirected to a pipe.
/*
***************************************************************************
- * Get local date and time.
+ * Get date and time, expressed in UTC or in local time.
*
* IN:
* @d_off Day offset (number of days to go back in the past).
+ * @utc TRUE if date and time shall be expressed in UTC.
*
* OUT:
* @rectime Current local date and time.
*
* RETURNS:
- * Value of time in seconds since the Epoch.
+ * Value of time in seconds since the Epoch (always in UTC)
***************************************************************************
*/
-time_t get_localtime(struct tm *rectime, int d_off)
+time_t get_xtime(struct tm *rectime, int d_off, int utc)
{
time_t timer;
timer = __time(NULL);
timer -= SEC_PER_DAY * d_off;
- localtime_r(&timer, rectime);
-
- return timer;
-}
-/*
- ***************************************************************************
- * Get date and time expressed in UTC.
- *
- * IN:
- * @d_off Day offset (number of days to go back in the past).
- *
- * OUT:
- * @rectime Current date and time expressed in UTC.
- *
- * RETURNS:
- * Value of time in seconds since the Epoch.
- ***************************************************************************
- */
-time_t get_gmtime(struct tm *rectime, int d_off)
-{
- time_t timer;
-
- timer = __time(NULL);
- timer -= SEC_PER_DAY * d_off;
- gmtime_r(&timer, rectime);
+ if (utc) {
+ /* Get date and time in UTC */
+ gmtime_r(&timer, rectime);
+ }
+ else {
+ /* Get date and time in local time */
+ localtime_r(&timer, rectime);
+ }
return timer;
}
utc++;
}
- if (utc == 2)
- return get_gmtime(rectime, d_off);
- else
- return get_localtime(rectime, d_off);
+ return get_xtime(rectime, d_off, utc == 2);
}
#ifdef USE_NLS
#define IGNORE_VIRTUAL_DEVICES FALSE
#define ACCEPT_VIRTUAL_DEVICES TRUE
+#define LOCAL_TIME FALSE
/* Environment variables */
#define ENV_TIME_FMT "S_TIME_FORMAT"
(void);
void get_kb_shift
(void);
-time_t get_localtime
- (struct tm *, int);
+time_t get_xtime
+ (struct tm *, int, int);
time_t get_time
(struct tm *, int);
void init_nls
}
/* Get time */
- get_localtime(rectime, 0);
+ get_xtime(rectime, 0, LOCAL_TIME);
/* Print results */
write_stats(curr, rectime, skip);
/* How many processors on this machine? */
cpu_nr = get_cpu_nr(~0, FALSE);
- get_localtime(&rectime, 0);
+ get_xtime(&rectime, 0, LOCAL_TIME);
/*
* Don't buffer data if redirected to a pipe.
memset(st_cpu[curr], 0, STATS_CPU_SIZE * (cpu_nr + 1));
/* Get time */
- get_localtime(&(mp_tstamp[curr]), 0);
+ get_xtime(&(mp_tstamp[curr]), 0, LOCAL_TIME);
/* Read uptime and CPU stats */
read_uptime(&(uptime_cs[curr]));
}
/* Get time */
- get_localtime(&(mp_tstamp[0]), 0);
+ get_xtime(&(mp_tstamp[0]), 0, LOCAL_TIME);
/*
* Don't buffer data if redirected to a pipe.
set_pid_nonexistent(pid_list);
/* Get time */
- get_localtime(&ps_tstamp[curr], 0);
+ get_xtime(&ps_tstamp[curr], 0, LOCAL_TIME);
/* Read system uptime (in 1/100th of a second) */
read_uptime(&(uptime_cs[curr]));
}
/* Get time */
- get_localtime(&(ps_tstamp[0]), 0);
+ get_xtime(&(ps_tstamp[0]), 0, LOCAL_TIME);
/*
* Don't buffer data if redirected to a pipe.
}
/* Get time */
- get_localtime(rectime, 0);
+ get_xtime(rectime, 0, LOCAL_TIME);
/* Check whether we should skip first report */
if (!skip) {
tape_initialise();
- get_localtime(&rectime, 0);
+ get_xtime(&rectime, 0, LOCAL_TIME);
/*
* Don't buffer data if redirected to a pipe.