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