Add parse_date_interactive()
Add a wrapper around parse_date() which picks the current input date format as well as the currently selected day and passes both values to parse_date(), alongside with the parameters passed to parse_date_interactive() itself. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
eddee590ec
commit
760c297027
@ -1150,8 +1150,8 @@ void print_bool_option_incolor(WINDOW *, unsigned, int, int);
|
|||||||
const char *get_tempdir(void);
|
const char *get_tempdir(void);
|
||||||
char *new_tempfile(const char *);
|
char *new_tempfile(const char *);
|
||||||
int check_date(unsigned, unsigned, unsigned);
|
int check_date(unsigned, unsigned, unsigned);
|
||||||
int parse_date(const char *, enum datefmt, int *, int *, int *,
|
int parse_date(const char *, enum datefmt, int *, int *, int *, struct date *);
|
||||||
struct date *);
|
int parse_date_interactive(const char *, int *, int *, int *);
|
||||||
int check_time(unsigned, unsigned);
|
int check_time(unsigned, unsigned);
|
||||||
int parse_time(const char *, unsigned *, unsigned *);
|
int parse_time(const char *, unsigned *, unsigned *);
|
||||||
int parse_duration(const char *, unsigned *);
|
int parse_duration(const char *, unsigned *);
|
||||||
|
10
src/ui-day.c
10
src/ui-day.c
@ -293,9 +293,8 @@ static void update_rept(struct rpt **rpt, const long start)
|
|||||||
new_date.mm = lt.tm_mon + 1;
|
new_date.mm = lt.tm_mon + 1;
|
||||||
new_date.yyyy = lt.tm_year + 1900;
|
new_date.yyyy = lt.tm_year + 1900;
|
||||||
} else {
|
} else {
|
||||||
if (!parse_date(timstr, conf.input_datefmt, &newyear,
|
if (!parse_date_interactive(timstr, &newyear,
|
||||||
&newmonth, &newday,
|
&newmonth, &newday)) {
|
||||||
ui_calendar_get_slctd_day())) {
|
|
||||||
asprintf(&outstr, msg_fmts,
|
asprintf(&outstr, msg_fmts,
|
||||||
DATEFMT_DESC(conf.input_datefmt));
|
DATEFMT_DESC(conf.input_datefmt));
|
||||||
status_mesg(msg_wrong_date, outstr);
|
status_mesg(msg_wrong_date, outstr);
|
||||||
@ -787,9 +786,8 @@ void ui_day_item_repeat(void)
|
|||||||
until_date.dd = lt.tm_mday;
|
until_date.dd = lt.tm_mday;
|
||||||
until_date.mm = lt.tm_mon + 1;
|
until_date.mm = lt.tm_mon + 1;
|
||||||
until_date.yyyy = lt.tm_year + 1900;
|
until_date.yyyy = lt.tm_year + 1900;
|
||||||
} else if (parse_date(user_input, conf.input_datefmt,
|
} else if (parse_date_interactive(user_input, &year, &month,
|
||||||
&year, &month, &day,
|
&day)) {
|
||||||
ui_calendar_get_slctd_day())) {
|
|
||||||
t = p->start;
|
t = p->start;
|
||||||
localtime_r(&t, <);
|
localtime_r(&t, <);
|
||||||
until_date.dd = day;
|
until_date.dd = day;
|
||||||
|
@ -886,6 +886,13 @@ parse_date(const char *date_string, enum datefmt datefmt, int *year,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
parse_date_interactive(const char *datestr, int *year, int *month, int *day)
|
||||||
|
{
|
||||||
|
return parse_date(datestr, conf.input_datefmt, year, month, day,
|
||||||
|
ui_calendar_get_slctd_day());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a date duration string into a number of days.
|
* Convert a date duration string into a number of days.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user