]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/btime.c
Fix reporting jobs from state file + misc
[bacula/bacula] / bacula / src / lib / btime.c
index 8cd302f472a1338acbdd1f8896102f9719ec1f74..f5e3a99b2cf3af1ef0eda3629a5688022c42dfb9 100644 (file)
@@ -4,7 +4,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -53,6 +53,21 @@ char *bstrftime(char *dt, int maxlen, utime_t tim)
    return dt;
 }
 
+/* Formatted time for user display: dd-Mon-yy hh:mm  (no century) */
+char *bstrftime_nc(char *dt, int maxlen, utime_t tim)
+{
+   time_t ttime = 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 */
+   strftime(dt, maxlen, "%d-%b-%Y %H:%M", &tm);
+   strcpy(dt+7, dt+9);
+   return dt;
+}
+
+
 /* Unix time to standard time string yyyy-mm-dd hh:mm:ss */
 char *bstrutime(char *dt, int maxlen, utime_t tim)
 {
@@ -121,7 +136,7 @@ utime_t btime_to_utime(btime_t bt)
 }
 
 /*
- * Return the week of the month, base 0 (wpos)
+ * Return the week of the month, base 0 (wom)
  *   given tm_mday and tm_wday. Value returned
  *   can be from 0 to 4 => week1, ... week5
  */
@@ -133,11 +148,11 @@ int tm_wom(int mday, int wday)
       fs += 7;
    }
    if (mday <= fs) {
-//    Dmsg2(100, "wom=0 wday=%d <= fs=%d\n", wday, fs);
+//    Dmsg3(100, "mday=%d wom=0 wday=%d <= fs=%d\n", mday, wday, fs);
       return 0;
    }
    int wom = 1 + (mday - fs - 1) / 7;
-// Dmsg3(100, "wom=%d wday=%d fs=%d\n", wom, wday, fs);
+// Dmsg4(100, "mday=%d wom=%d wday=%d fs=%d\n", mday, wom, wday, fs);
    return wom;
 }