From 0bb4a59b5fb089062f0eb369d39289ff1ccfc2ba Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Thu, 27 Dec 2018 12:08:25 +0100 Subject: Add week numbers in the calendar and full first and last week Much in the calendar is based on the selected day, struct date slctd_day, in ui-calendar.c. On the screen it is highlighted with a deviating colour. The highlight effect has been changed to a pair of red square brackets that do not obscure the day colour. The week number (in the frame) used to be that of the selected day, but has no obvious relation to the days in the APP panel. It has been replaced by the year day number of the selected day. The week numbers of all visible weeks are displayed to the left of the calendar. Dates are displayed also for the overlapping parts of the first and last week of the month (which do not belong to the month). Days are accessible in the appointments panel as well as in the calendar. Hence, validation of days (= inside UNIX time limits) must be extended from the calendar (in ui_calendar_move()) to include loaded days (in day_store_items()). Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/day.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/day.c') diff --git a/src/day.c b/src/day.c index c340988..c88713c 100644 --- a/src/day.c +++ b/src/day.c @@ -437,6 +437,9 @@ day_store_items(time_t date, int include_captions, int n) day_init_vector(); for (i = 0; i < n; i++, date = NEXTDAY(date)) { + if (YEAR1902_2037 && !check_sec(&date)) + break; + if (include_captions) day_add_item(DAY_HEADING, 0, date, p); @@ -584,10 +587,10 @@ void day_popup_item(struct day_item *day) } /* - * Check whether there is an item on a given day. - * - * Returns 2 if the selected day contains a regular event or appointment. - * Returns 1 if the selected day does not contain a regular event or + * Check whether there is an item on a given day and return the colour + * attribute for the item: + * ATTR_TRUE if the selected day contains a regular event or appointment, + * ATTR_LOW if the selected day does not contain a regular event or * appointment but an occurrence of a recurrent item. Returns 0 otherwise. */ int day_check_if_item(struct date day) @@ -595,23 +598,23 @@ int day_check_if_item(struct date day) const time_t t = date2sec(day, 0, 0); if (LLIST_FIND_FIRST(&eventlist, (time_t *)&t, event_inday)) - return 2; + return ATTR_TRUE; LLIST_TS_LOCK(&alist_p); if (LLIST_TS_FIND_FIRST(&alist_p, (time_t *)&t, apoint_inday)) { LLIST_TS_UNLOCK(&alist_p); - return 2; + return ATTR_TRUE; } LLIST_TS_UNLOCK(&alist_p); if (LLIST_FIND_FIRST(&recur_elist, (time_t *)&t, recur_event_inday)) - return 1; + return ATTR_LOW; LLIST_TS_LOCK(&recur_alist_p); if (LLIST_TS_FIND_FIRST(&recur_alist_p, (time_t *)&t, recur_apoint_inday)) { LLIST_TS_UNLOCK(&recur_alist_p); - return 1; + return ATTR_LOW; } LLIST_TS_UNLOCK(&recur_alist_p); -- cgit v1.2.3-54-g00ecf