From 3d7bb89c8886f6c318d26820ed4c0e6c25f9c959 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Fri, 29 Dec 2017 20:59:53 +0100 Subject: CLI: take input date format from configuration file, do not accept time Before this patch the input date parsing accepts three formats: yyyy/mm/dd, mm/dd/yyyy, yyyy-mm-dd. They are tried in sequence. It also accepts an additional time (hh:mm), or a time without a date. There are several issues with this: - it is not documented - the date format dd/mm/yyyy is not accepted - print_date() and filter option settings (in parse_args()) can only handle midnight times (which are the result of a date without time) - it is highly uncertain what happens if a time (without a date) is given; at least the -d option treats a time without colon (1215 for 12:15) as a number It seems that acceptance of time input is a by-product and not needed. For these reasons the input date parsing has been changed: - the format is taken from the configuration file (as is the case for the output date format) - only a date, and no time, is accepted Because the input date format is used during parsing of the command line, the configuration file must be loaded first, i.e. the options -D or -C must be parsed before the remaining ones. Loading the configuration file may result in errors (e.g. caused by changes between versions). For this reason config_load() has been made more tolerant and issues warnings instead of exiting. A followup patch will introduce two options to allow the configuration file settings to be overridden for input and output date formats. Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/config.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index 61527be..ca81c67 100644 --- a/src/config.c +++ b/src/config.c @@ -629,12 +629,9 @@ static int config_load_cb(const char *key, const char *value, void *dummy) int result = config_set_conf(key, value); if (result < 0) { - EXIT(_("configuration variable unknown: \"%s\""), key); - /* NOTREACHED */ + WARN_MSG(_("unknown user option: \"%s\""), key); } else if (result == 0) { - EXIT(_("wrong configuration variable format for \"%s\""), - key); - /* NOTREACHED */ + WARN_MSG(_("invalid option format: \"%s\""), key); } return 1; -- cgit v1.2.3-54-g00ecf