From: Thibault Godouet Date: Mon, 9 Jun 2014 17:09:02 +0000 (+0100) Subject: print dates and time in standard formats. X-Git-Tag: ver3_2_0~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2ed024ac35a286105fdb7c932f46991f75a9bc7e;p=thirdparty%2Ffcron.git print dates and time in standard formats. --- diff --git a/conf.c b/conf.c index 0659e86..3f2b327 100644 --- 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 */ diff --git a/database.c b/database.c index ab60bea..9d76f48 100644 --- a/database.c +++ b/database.c @@ -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; diff --git a/doc/en/changes.sgml b/doc/en/changes.sgml index d6c349a..7797f0f 100644 --- a/doc/en/changes.sgml +++ b/doc/en/changes.sgml @@ -12,6 +12,13 @@ A copy of the license is included in gfdl.sgml. Changes + + From version 3.1.3 to 3.2.0 + + 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). + + + From version 3.1.2 to 3.1.3 diff --git a/doc/en/todo.sgml b/doc/en/todo.sgml index 39b733e..9ece3fd 100644 --- a/doc/en/todo.sgml +++ b/doc/en/todo.sgml @@ -23,15 +23,9 @@ A copy of the license is included in gfdl.sgml. High priority - - Update FAQ - anacron entry - Option to compile and install from git sources without generating the doc - - print date using locales (e.g. DD/MM/YYYY vs. MM/DD/YYYY) - diff --git a/fcron.c b/fcron.c index ec65f36..8155ee6 100644 --- 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); } } diff --git a/fcronsighup.c b/fcronsighup.c index 6a34b2e..6a55b94 100644 --- a/fcronsighup.c +++ b/fcronsighup.c @@ -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); diff --git a/socket.c b/socket.c index 8fa5e4a..6e13c00 100644 --- 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);