* in Bacula (fdate_t, ftime_t, time_t (Unix standard), btime_t, and
* utime_t). fdate_t and ftime_t are deprecated and should no longer
* be used, and in general, Unix time time_t should no longer be used,
- * it is being phased out.
- *
- * Epoch is the base of Unix time in seconds (time_t, ...)
+ * it is being phased out.
+ *
+ * Epoch is the base of Unix time in seconds (time_t, ...)
* and is 1 Jan 1970 at 0:0 UTC
*
* The major two times that should be left are:
{
time_t ttime = (time_t)tim;
struct tm tm;
-
+
/* ***FIXME**** the format and localtime_r() should be user configurable */
localtime_r(&ttime, &tm);
strftime(dt, maxlen, "%d-%b-%Y %H:%M", &tm);
{
time_t ttime = (time_t)tim;
struct tm tm;
-
+
/* ***FIXME**** the format and localtime_r() should be user configurable */
localtime_r(&ttime, &tm);
strftime(dt, maxlen, "%d-%b-%Y %H:%M:%S", &tm);
{
time_t ttime = (time_t)tim;
struct tm tm;
-
+
/* ***FIXME**** the format and localtime_r() should be user configurable */
localtime_r(&ttime, &tm);
strftime(dt, maxlen, "%d-%b %H:%M", &tm);
{
time_t ttime = (time_t)tim;
struct tm tm;
-
+
/* ***FIXME**** the format and localtime_r() should be user configurable */
localtime_r(&ttime, &tm);
/* NOTE! since the compiler complains about %y, I use %y and cut the century */
}
/* Convert standard time string yyyy-mm-dd hh:mm:ss to Unix time */
-utime_t str_to_utime(char *str)
+utime_t str_to_utime(char *str)
{
struct tm tm;
time_t ttime;
}
if (tm.tm_mon > 0) {
tm.tm_mon--;
- } else {
+ } else {
return 0;
}
if (tm.tm_year >= 1900) {
tm.tm_wday = tm.tm_yday = 0;
tm.tm_isdst = -1;
ttime = mktime(&tm);
- if (ttime == -1) {
+ if (ttime == -1) {
ttime = 0;
}
return (utime_t)ttime;
/* Convert btime to Unix time */
time_t btime_to_unix(btime_t bt)
{
- return (time_t)(bt/1000000);
+ return (time_t)(bt/1000000);
}
/* Convert btime to utime */
int wom = 1 + (mday - fs - 1) / 7;
// Dmsg4(100, "mday=%d wom=%d wday=%d fs=%d\n", mday, wom, wday, fs);
return wom;
-}
+}
/*
* Given a Unix date return the week of the year.
time_decode(dt->julian_day_fraction, hour, minute, second, second_fraction);
}
-/* tm_encode -- Encode a civil date and time from a tm structure
+/* tm_encode -- Encode a civil date and time from a tm structure
* to a Julian day and day fraction.
*/
/* Deprecated. Do not use. */
void tm_encode(struct date_time *dt,
- struct tm *tm)
+ struct tm *tm)
{
uint32_t year;
uint8_t month, day, hour, minute, second;
/* Deprecated. Do not use. */
void tm_decode(struct date_time *dt,
- struct tm *tm)
+ struct tm *tm)
{
uint32_t year;
uint8_t month, day, hour, minute, second;