]> granicus.if.org Git - fcron/commitdiff
print dates and time in standard formats.
authorThibault Godouet <fcron@free.fr>
Mon, 9 Jun 2014 17:09:02 +0000 (18:09 +0100)
committerThibault Godouet <fcron@free.fr>
Mon, 9 Jun 2014 17:09:02 +0000 (18:09 +0100)
conf.c
database.c
doc/en/changes.sgml
doc/en/todo.sgml
fcron.c
fcronsighup.c
socket.c

diff --git a/conf.c b/conf.c
index 0659e86d115bff671649919f4b2692bb060fe47a..3f2b32733a06897b99064de12b20b5d51e54c686 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -308,12 +308,13 @@ synchronize_file(char *file_name, int is_system_startup)
                         if (debug_opt && !is_hasrun(new_l->cl_option)) {
                             struct tm *ftime;
                             ftime = localtime(&new_l->cl_nextexe);
-                            debug("  from last conf: %s next exec %d/%d/%d"
-                                  " wday:%d %02d:%02d:%02d (system time)",
-                                  new_l->cl_shell,
-                                  (ftime->tm_mon + 1), ftime->tm_mday,
-                                  (ftime->tm_year + 1900), ftime->tm_wday,
-                                  ftime->tm_hour, ftime->tm_min, ftime->tm_sec);
+                            debug
+                                ("  from last conf: %s next exec %04d-%02d-%02d"
+                                 " wday:%d %02d:%02d:%02d (system time)",
+                                 new_l->cl_shell, (ftime->tm_year + 1900),
+                                 (ftime->tm_mon + 1), ftime->tm_mday,
+                                 ftime->tm_wday, ftime->tm_hour, ftime->tm_min,
+                                 ftime->tm_sec);
                         }
 
                         break;
@@ -993,11 +994,11 @@ add_line_to_file(cl_t * cl, cf_t * cf, uid_t runas, char *runas_str,
     if (debug_opt && !(is_runonce(cl->cl_option) && is_hasrun(cl->cl_option))) {
         struct tm *ftime;
         ftime = localtime(&(cl->cl_nextexe));
-        debug("  cmd %s next exec %d/%d/%d wday:%d %02d:%02d:%02d"
+        debug("  cmd %s next exec %04d-%02d-%02d wday:%d %02d:%02d:%02d"
               " (system time)",
-              cl->cl_shell, (ftime->tm_mon + 1), ftime->tm_mday,
-              (ftime->tm_year + 1900), ftime->tm_wday,
-              ftime->tm_hour, ftime->tm_min, ftime->tm_sec);
+              cl->cl_shell, (ftime->tm_year + 1900), (ftime->tm_mon + 1),
+              ftime->tm_mday, ftime->tm_wday, ftime->tm_hour, ftime->tm_min,
+              ftime->tm_sec);
     }
 
     /* add the current line to the list, and allocate a new line */
index ab60beaf019095d76651c438c92cfa1d1aaa1f03..9d76f489a76dd14043ef65fa0977a5b962dd8ad0 100644 (file)
@@ -761,9 +761,9 @@ goto_beginning_next_period_periodical(cl_t * line, struct tm *ftime)
 
     if (debug_opt)
         set_wday(ftime);
-    debug("   %s beginning of next period %d/%d/%d wday:%d %02d:%02d "
-          "(tzdiff=%d, timezone=%s)", line->cl_shell, (ftime->tm_mon + 1),
-          ftime->tm_mday, (ftime->tm_year + 1900), ftime->tm_wday,
+    debug("   %s beginning of next period %04d-%02d-%02d wday:%d %02d:%02d "
+          "(tzdiff=%d, timezone=%s)", line->cl_shell, (ftime->tm_year + 1900),
+          (ftime->tm_mon + 1), ftime->tm_mday, ftime->tm_wday,
           ftime->tm_hour, ftime->tm_min, line->cl_file->cf_tzdiff,
           (line->cl_tz != NULL) ? line->cl_tz : "localtime");
 
@@ -944,11 +944,11 @@ move_time_to(int where, cl_t * line, struct tm *ftime)
         }
     }
 
-    debug("   %s %s %d/%d/%d wday:%d %02d:%02d (tzdiff=%d, timezone=%s)",
+    debug("   %s %s %04d-%02d-%02d wday:%d %02d:%02d (tzdiff=%d, timezone=%s)",
           line->cl_shell,
           (where ==
            END_OF_INTERVAL) ? "end of interval" : "begin of next period",
-          (ftime->tm_mon + 1), ftime->tm_mday, (ftime->tm_year + 1900),
+          (ftime->tm_year + 1900), (ftime->tm_mon + 1), ftime->tm_mday,
           ftime->tm_wday, ftime->tm_hour, ftime->tm_min,
           line->cl_file->cf_tzdiff,
           (line->cl_tz != NULL) ? line->cl_tz : "localtime");
@@ -1155,9 +1155,9 @@ set_next_exe(cl_t * line, char option, int info_fd)
             struct tm int_end;
             time_t int_end_timet;
 
-            debug("   cmd: %s begin int exec %d/%d/%d wday:%d %02d:%02d "
+            debug("   cmd: %s begin int exec %04d-%02d-%02d wday:%d %02d:%02d "
                   "(tzdiff=%d, timezone=%s)", line->cl_shell,
-                  (ftime.tm_mon + 1), ftime.tm_mday, (ftime.tm_year + 1900),
+                  (ftime.tm_year + 1900), (ftime.tm_mon + 1), ftime.tm_mday,
                   ftime.tm_wday, ftime.tm_hour, ftime.tm_min,
                   line->cl_file->cf_tzdiff,
                   (line->cl_tz != NULL) ? line->cl_tz : "localtime");
@@ -1188,10 +1188,11 @@ set_next_exe(cl_t * line, char option, int info_fd)
                 ft = localtime(&nextexe);
                 memcpy(&ftime, ft, sizeof(ftime));
             }
-            send_msg_fd_debug(info_fd, "   cmd: %s next exec %d/%d/%d wday:%d "
+            send_msg_fd_debug(info_fd,
+                              "   cmd: %s next exec %04d-%02d-%02d wday:%d "
                               "%02d:%02d:%02d (tzdiff=%d, timezone=%s)",
-                              line->cl_shell, (ftime.tm_mon + 1), ftime.tm_mday,
-                              (ftime.tm_year + 1900), ftime.tm_wday,
+                              line->cl_shell, (ftime.tm_year + 1900),
+                              (ftime.tm_mon + 1), ftime.tm_mday, ftime.tm_wday,
                               ftime.tm_hour, ftime.tm_min, ftime.tm_sec,
                               line->cl_file->cf_tzdiff,
                               (line->cl_tz != NULL) ? line->cl_tz : "system's");
@@ -1250,10 +1251,11 @@ set_next_exe(cl_t * line, char option, int info_fd)
          * ( localtime() is used in the debug() function) */
         memcpy(&ftime, ft, sizeof(struct tm));
 
-        send_msg_fd_debug(info_fd, "   cmd: %s next exec %d/%d/%d wday:%d "
+        send_msg_fd_debug(info_fd,
+                          "   cmd: %s next exec %04d-%02d-%02d wday:%d "
                           "%02d:%02d:%02d (system time)", line->cl_shell,
-                          (ftime.tm_mon + 1), ftime.tm_mday,
-                          (ftime.tm_year + 1900), ftime.tm_wday, ftime.tm_hour,
+                          (ftime.tm_year + 1900), (ftime.tm_mon + 1),
+                          ftime.tm_mday, ftime.tm_wday, ftime.tm_hour,
                           ftime.tm_min, ftime.tm_sec);
     }
 
@@ -1394,35 +1396,39 @@ mail_notrun(cl_t * line, char context, struct tm *since)
     switch (context) {
     case SYSDOWN:
         fprintf(mailf, "Line %s has not run since and including "
-                "%d/%d/%d wday:%d %02d:%02d (timezone=%s)\n"
+                "%04d-%02d-%02d wday:%d %02d:%02d (timezone=%s)\n"
                 "due to system's down state.\n",
-                line->cl_shell, (since->tm_mon + 1), since->tm_mday,
-                (since->tm_year + 1900), since->tm_wday, since->tm_hour,
-                since->tm_min, (line->cl_tz) ? line->cl_tz : "system's");
-        fprintf(mailf, "It will be next executed at %d/%d/%d wday:"
-                "%d %02d:%02d\n", (time.tm_mon + 1), time.tm_mday,
-                (time.tm_year + 1900), time.tm_wday, time.tm_hour, time.tm_min);
+                line->cl_shell, (since->tm_year + 1900), (since->tm_mon + 1),
+                since->tm_mday, since->tm_wday, since->tm_hour, since->tm_min,
+                (line->cl_tz) ? line->cl_tz : "system's");
+        fprintf(mailf,
+                "It will be next executed at %04d-%02d-%02d wday:"
+                "%d %02d:%02d\n", (time.tm_year + 1900), (time.tm_mon + 1),
+                time.tm_mday, time.tm_wday, time.tm_hour, time.tm_min);
         break;
     case LAVG:
         fprintf(mailf, "Line %s has not run since and including "
-                "%d/%d/%d wday:%d %02d:%02d (timezone=%s)\n",
-                line->cl_shell, (since->tm_mon + 1), since->tm_mday,
-                (since->tm_year + 1900), since->tm_wday, since->tm_hour,
-                since->tm_min, (line->cl_tz) ? line->cl_tz : "system's");
-        fprintf(mailf, "due to a too high system load average or "
+                "%04d-%02d-%02d wday:%d %02d:%02d (timezone=%s)\n",
+                line->cl_shell, (since->tm_year + 1900), (since->tm_mon + 1),
+                since->tm_mday, since->tm_wday, since->tm_hour, since->tm_min,
+                (line->cl_tz) ? line->cl_tz : "system's");
+        fprintf(mailf,
+                "due to a too high system load average or "
                 "too many lavg-serial jobs.\n");
-        fprintf(mailf, "It will be next executed at %d/%d/%d "
-                "wday:%d %02d:%02d (timezone=%s)\n", (time.tm_mon + 1),
-                time.tm_mday, (time.tm_year + 1900), time.tm_wday, time.tm_hour,
+        fprintf(mailf,
+                "It will be next executed at %04d-%02d-%02d "
+                "wday:%d %02d:%02d (timezone=%s)\n", (time.tm_year + 1900),
+                (time.tm_mon + 1), time.tm_mday, time.tm_wday, time.tm_hour,
                 time.tm_min, (line->cl_tz) ? line->cl_tz : "system's");
         break;
     case QUEUE_FULL:
         fprintf(mailf, "Line %s couldn't be added to lavg or serial queue which"
-                " is full ( %d/%d/%d wday:%d %02d:%02d (timezone=%s)).\n",
-                line->cl_shell, (time.tm_mon + 1), time.tm_mday,
-                (time.tm_year + 1900), time.tm_wday, time.tm_hour, time.tm_min,
+                " is full ( %04d-%02d-%02d wday:%d %02d:%02d (timezone=%s)).\n",
+                line->cl_shell, (time.tm_year + 1900), (time.tm_mon + 1),
+                time.tm_mday, time.tm_wday, time.tm_hour, time.tm_min,
                 (line->cl_tz) ? line->cl_tz : "system's");
-        fprintf(mailf, "Consider using options lavgonce, until, strict, "
+        fprintf(mailf,
+                "Consider using options lavgonce, until, strict, "
                 "serialonce and/or fcron's option -m.\n");
         fprintf(mailf, "Note that job %s has not run.\n", line->cl_shell);
         break;
index d6c349af96523d55f4037ea6f05d5c850773f268..7797f0fdc6e19e9fb2e500710e66ff228e8c7bd9 100644 (file)
@@ -12,6 +12,13 @@ A copy of the license is included in gfdl.sgml.
    <sect1 id="changes">
       <title>Changes</title>
 
+      <itemizedlist>
+        <title>From version 3.1.3 to 3.2.0</title>
+           <listitem>
+              <para>Print date as %Y-%m-%d (the ISO 8601 date format), to avoid being ambiguous in international context.  Also always use the ':' as hour:minute separator (there was a couple of 'h' instead).</para>
+           </listitem>
+      </itemizedlist>
+
       <itemizedlist>
         <title>From version 3.1.2 to 3.1.3</title>
            <listitem>
index 39b733edff33fb1730dd2ec89f90a6c3f9a64938..9ece3fdd1a2df83b04774a0bd393c1c069258a41 100644 (file)
@@ -23,15 +23,9 @@ A copy of the license is included in gfdl.sgml.
       <sect2>
         <title>High priority</title>
         <itemizedlist>
-           <listitem>
-              <para>Update FAQ - anacron entry</para>
-           </listitem>
            <listitem>
               <para>Option to compile and install from git sources without generating the doc</para>
            </listitem>
-           <listitem>
-              <para>print date using locales (e.g. DD/MM/YYYY vs. MM/DD/YYYY)</para>
-           </listitem>
            <listitem>
               <para></para>
            </listitem>
diff --git a/fcron.c b/fcron.c
index ec65f3640226b156b2eea574cb0d64ade32be926..8155ee6f40f80e48cbac8ab58e7abc8ea6beb18a 100644 (file)
--- a/fcron.c
+++ b/fcron.c
@@ -173,11 +173,11 @@ print_schedule(void)
         explain(" File %s", cf->cf_user);
         for (cl = cf->cf_line_base; cl; cl = cl->cl_next) {
             ftime = localtime(&(cl->cl_nextexe));
-            explain("  cmd %s next exec %d/%d/%d wday:%d %02d:%02d"
+            explain("  cmd %s next exec %04d-%02d-%02d wday:%d %02d:%02d"
                     " (system time)",
-                    cl->cl_shell, (ftime->tm_mon + 1), ftime->tm_mday,
-                    (ftime->tm_year + 1900), ftime->tm_wday,
-                    ftime->tm_hour, ftime->tm_min);
+                    cl->cl_shell, (ftime->tm_year + 1900), (ftime->tm_mon + 1),
+                    ftime->tm_mday, ftime->tm_wday, ftime->tm_hour,
+                    ftime->tm_min);
 
         }
     }
index 6a34b2e18daaaf072b32400af851f0872d502af0..6a55b94f1845cc3dca1f2d001a0b20b26e0d6fd6 100644 (file)
@@ -105,7 +105,7 @@ sig_daemon(void)
                 tm->tm_hour++;
                 tm->tm_min -= 60;
             }
-            snprintf(buf, sizeof(buf), "%02dh%02d", tm->tm_hour, tm->tm_min);
+            snprintf(buf, sizeof(buf), "%02d:%02d", tm->tm_hour, tm->tm_min);
             sl = 60 - (t % 60) + 50;
         }
         else {
@@ -113,7 +113,7 @@ sig_daemon(void)
                 tm->tm_hour++;
                 tm->tm_min -= 60;
             }
-            snprintf(buf, sizeof(buf), "%02dh%02d", tm->tm_hour, tm->tm_min);
+            snprintf(buf, sizeof(buf), "%02d:%02d", tm->tm_hour, tm->tm_min);
         }
         fprintf(stderr, "Modifications will be taken into account"
                 " at %s.\n", buf);
index 8fa5e4a61afc6c4fa0633474eb80b1375f1236fd..6e13c00e5d1d4de973a26da8210f7fd668db9aa0 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -496,9 +496,9 @@ print_line(int fd, struct cl_t *line, unsigned char *details, pid_t pid,
             ftime = localtime(&until);
             len +=
                 snprintf(buf + len, sizeof(buf) - len,
-                         " %02d/%02d/%d %02d:%02d %s", (ftime->tm_mon + 1),
-                         ftime->tm_mday, (ftime->tm_year + 1900),
-                         ftime->tm_hour, ftime->tm_min,
+                         " %04d-%02d-%02d %02d:%02d %s",
+                         (ftime->tm_year + 1900), (ftime->tm_mon + 1),
+                         ftime->tm_mday, ftime->tm_hour, ftime->tm_min,
                          (is_strict(line->cl_option)) ? "Y" : "N");
         }
         else
@@ -508,9 +508,10 @@ print_line(int fd, struct cl_t *line, unsigned char *details, pid_t pid,
     }
     if (bit_test(details, FIELD_SCHEDULE)) {
         ftime = localtime(&(line->cl_nextexe));
-        len += snprintf(buf + len, sizeof(buf) - len, " %02d/%02d/%d %02d:%02d",
-                        (ftime->tm_mon + 1), ftime->tm_mday,
-                        (ftime->tm_year + 1900), ftime->tm_hour, ftime->tm_min);
+        len +=
+            snprintf(buf + len, sizeof(buf) - len, " %04d-%02d-%02d %02d:%02d",
+                     (ftime->tm_year + 1900), (ftime->tm_mon + 1),
+                     ftime->tm_mday, ftime->tm_hour, ftime->tm_min);
     }
     len += snprintf(buf + len, sizeof(buf) - len, " %s\n", line->cl_shell);