0745245
This patch should resolve some problems with handling of am/pm
0745245
in schedules as reported by bug #808.
0745245
0745245
According to the NIST (US National Institute of Standards and Technology),
0745245
12am and 12pm are ambiguous and can be defined to anything.  However,
0745245
12:01am is the same as 00:01 and 12:01pm is the same as 12:01, so Bacula
0745245
defines 12am as 00:00 (midnight) and 12pm as 12:00 (noon).  You can avoid
0745245
this abiguity (confusion) by using 24 hour time specifications (i.e.  no
0745245
am/pm). This is the definition in Bacula version 2.0.3 and later.
0745245
0745245
Apply it to version 2.0.3 with:
0745245
0745245
  cd <bacula-source>
0745245
  patch -p0 <2.0.3-ampm.patch
0745245
  make
0745245
  ...
0745245
  make install
0745245
0745245
Index: src/dird/run_conf.c
0745245
===================================================================
0745245
--- src/dird/run_conf.c	(revision 4349)
0745245
+++ src/dird/run_conf.c	(working copy)
0745245
@@ -339,6 +339,7 @@
0745245
    for ( ; token != T_EOL; (token = lex_get_token(lc, T_ALL))) {
0745245
       int len; 
0745245
       bool pm = false;
0745245
+      bool am = false;
0745245
       switch (token) {
0745245
       case T_NUMBER:
0745245
          state = s_mday;
0745245
@@ -434,6 +435,7 @@
0745245
          if (!have_hour) {
0745245
             clear_bits(0, 23, lrun.hour);
0745245
          }
0745245
+//       Dmsg1(000, "s_time=%s\n", lc->str);
0745245
          p = strchr(lc->str, ':');
0745245
          if (!p)  {
0745245
             scan_err0(lc, _("Time logic error.\n"));
0745245
@@ -441,20 +443,19 @@
0745245
          }
0745245
          *p++ = 0;                 /* separate two halves */
0745245
          code = atoi(lc->str);     /* pick up hour */
0745245
+         code2 = atoi(p);          /* pick up minutes */
0745245
          len = strlen(p);
0745245
-         if (len > 2 && p[len-1] == 'm') {
0745245
-            if (p[len-2] == 'a') {
0745245
-               pm = false;
0745245
-            } else if (p[len-2] == 'p') {
0745245
-               pm = true;
0745245
-            } else {
0745245
-               scan_err0(lc, _("Bad time specification."));
0745245
-               /* NOT REACHED */
0745245
-            }
0745245
-         } else {
0745245
-            pm = false;
0745245
+         if (len >= 2) {
0745245
+            p += 2;
0745245
          }
0745245
-         code2 = atoi(p);             /* pick up minutes */
0745245
+         if (strcasecmp(p, "pm") == 0) {
0745245
+            pm = true;
0745245
+         } else if (strcasecmp(p, "am") == 0) {
0745245
+            am = true;
0745245
+         } else if (len != 2) {
0745245
+            scan_err0(lc, _("Bad time specification."));
0745245
+            /* NOT REACHED */
0745245
+         }   
0745245
          /* 
0745245
           * Note, according to NIST, 12am and 12pm are ambiguous and
0745245
           *  can be defined to anything.  However, 12:01am is the same
0745245
@@ -467,13 +468,14 @@
0745245
                code += 12;
0745245
             }
0745245
          /* am */
0745245
-         } else if (code == 12) {
0745245
+         } else if (am && code == 12) {
0745245
             code -= 12;
0745245
          }
0745245
          if (code < 0 || code > 23 || code2 < 0 || code2 > 59) {
0745245
             scan_err0(lc, _("Bad time specification."));
0745245
             /* NOT REACHED */
0745245
          }
0745245
+//       Dmsg2(000, "hour=%d min=%d\n", code, code2);
0745245
          set_bit(code, lrun.hour);
0745245
          lrun.minute = code2;
0745245
          have_hour = true;