Add support for --filter-end-* to events
A natural convention is to specify the end time of an event as 23:59:59 on the day it is scheduled. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
794e950942
commit
41b3ab7d17
@ -124,7 +124,7 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note,
|
|||||||
struct item_filter *filter)
|
struct item_filter *filter)
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ], *nl;
|
char buf[BUFSIZ], *nl;
|
||||||
time_t tstart;
|
time_t tstart, tend;
|
||||||
|
|
||||||
EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) ||
|
EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) ||
|
||||||
!check_time(start.tm_hour, start.tm_min),
|
!check_time(start.tm_hour, start.tm_min),
|
||||||
@ -147,6 +147,7 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note,
|
|||||||
|
|
||||||
tstart = mktime(&start);
|
tstart = mktime(&start);
|
||||||
EXIT_IF(tstart == -1, _("date error in the event\n"));
|
EXIT_IF(tstart == -1, _("date error in the event\n"));
|
||||||
|
tend = tstart + DAYINSEC - 1;
|
||||||
|
|
||||||
/* Filter item. */
|
/* Filter item. */
|
||||||
if (filter) {
|
if (filter) {
|
||||||
@ -158,6 +159,10 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note,
|
|||||||
return NULL;
|
return NULL;
|
||||||
if (filter->start_to >= 0 && tstart > filter->start_to)
|
if (filter->start_to >= 0 && tstart > filter->start_to)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (filter->end_from >= 0 && tend < filter->end_from)
|
||||||
|
return NULL;
|
||||||
|
if (filter->end_to >= 0 && tend > filter->end_to)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return event_new(buf, note, tstart, id);
|
return event_new(buf, note, tstart, id);
|
||||||
|
@ -403,7 +403,7 @@ struct recur_event *recur_event_scan(FILE * f, struct tm start, int id,
|
|||||||
struct item_filter *filter)
|
struct item_filter *filter)
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ], *nl;
|
char buf[BUFSIZ], *nl;
|
||||||
time_t tstart, tuntil;
|
time_t tstart, tend, tuntil;
|
||||||
|
|
||||||
EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) ||
|
EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) ||
|
||||||
!check_time(start.tm_hour, start.tm_min) ||
|
!check_time(start.tm_hour, start.tm_min) ||
|
||||||
@ -434,6 +434,7 @@ struct recur_event *recur_event_scan(FILE * f, struct tm start, int id,
|
|||||||
}
|
}
|
||||||
tstart = mktime(&start);
|
tstart = mktime(&start);
|
||||||
EXIT_IF(tstart == -1 || tuntil == -1, _("date error in event"));
|
EXIT_IF(tstart == -1 || tuntil == -1, _("date error in event"));
|
||||||
|
tend = tstart + DAYINSEC - 1;
|
||||||
|
|
||||||
/* Filter item. */
|
/* Filter item. */
|
||||||
if (filter) {
|
if (filter) {
|
||||||
@ -445,6 +446,10 @@ struct recur_event *recur_event_scan(FILE * f, struct tm start, int id,
|
|||||||
return NULL;
|
return NULL;
|
||||||
if (filter->start_to >= 0 && tstart > filter->start_to)
|
if (filter->start_to >= 0 && tstart > filter->start_to)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (filter->end_from >= 0 && tend < filter->end_from)
|
||||||
|
return NULL;
|
||||||
|
if (filter->end_to >= 0 && tend > filter->end_to)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return recur_event_new(buf, note, tstart, id, recur_char2def(type),
|
return recur_event_new(buf, note, tstart, id, recur_char2def(type),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user