summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/calcurse.h5
-rw-r--r--src/config.c2
-rw-r--r--src/custom.c2
3 files changed, 6 insertions, 3 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 9efb4fd..5fdfe4c 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -247,14 +247,17 @@ struct dmon_conf {
unsigned log; /* log daemon activity */
};
+/* Input date formats. */
enum datefmt {
DATEFMT_MMDDYYYY = 1,
DATEFMT_DDMMYYYY,
DATEFMT_YYYYMMDD,
DATEFMT_ISO,
- DATE_FORMATS
+ DATEFMT_MAX
};
+#define DATE_FORMATS (DATEFMT_MAX - 1)
+
#define DATEFMT(datefmt) (datefmt == DATEFMT_MMDDYYYY ? "%m/%d/%Y" : \
(datefmt == DATEFMT_DDMMYYYY ? "%d/%m/%Y" : \
(datefmt == DATEFMT_YYYYMMDD ? "%Y/%m/%d" : "%Y-%m-%d")))
diff --git a/src/config.c b/src/config.c
index bb6ddf7..17ac848 100644
--- a/src/config.c
+++ b/src/config.c
@@ -243,7 +243,7 @@ static int config_parse_output_datefmt(void *dummy, const char *val)
static int config_parse_input_datefmt(void *dummy, const char *val)
{
if (config_parse_int(&conf.input_datefmt, val)) {
- if (conf.input_datefmt <= 0 || conf.input_datefmt >= DATE_FORMATS)
+ if (conf.input_datefmt <= 0 || conf.input_datefmt > DATE_FORMATS)
conf.input_datefmt = 1;
return 1;
} else
diff --git a/src/custom.c b/src/custom.c
index b8bd89b..049f0ff 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -792,7 +792,7 @@ void custom_general_config(void)
case '0':
val = status_ask_simplechoice(input_datefmt_prefix,
input_datefmt_choices,
- DATE_FORMATS - 1);
+ DATE_FORMATS);
if (val != -1)
conf.input_datefmt = val;
break;