summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2017-10-03 21:52:19 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2017-10-17 08:42:40 +0200
commiteeb7038c134dbe623feb1bf7a6c4549e54343e0f (patch)
tree816370a48725ce26832437b08dcd74bf8cfa44ee /src
parent8ee78c14af3b9974ad96cf85f6ea32c4e254f958 (diff)
downloadcalcurse-eeb7038c134dbe623feb1bf7a6c4549e54343e0f.tar.gz
calcurse-eeb7038c134dbe623feb1bf7a6c4549e54343e0f.zip
Do not tie ISO 8601 week numbering to Monday
The week number in the calendar panel is calculated according to ISO 8601. Hence, Monday is the first day of the week and the week number changes from Sunday to Monday. However, calcurse ties the week number not to Monday, but to the first day of the week as configured for display. Thus, when Sunday is shown as first day of the week, the week number is correct for Sunday, but wrong for the rest of the week (one behind). With this patch the week number always follows the mon-sun week as required by ISO 8601. A side effect is that when Sunday is displayed as first day of the week, and Sunday is the selected day, the week number displayed is invalid for the rest of the week (but changes to the correct one when the selected day moves forward). This raises the question whether the week numbering scheme should follow the "first day of the week" choice and use the American week numbering scheme instead of ISO 8601 when Sunday is the first day of the week. But that is for the future. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/ui-calendar.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ui-calendar.c b/src/ui-calendar.c
index a2a0e8b..93115da 100644
--- a/src/ui-calendar.c
+++ b/src/ui-calendar.c
@@ -356,7 +356,7 @@ draw_monthly_view(struct scrollwin *sw, struct date *current_day,
unsigned yr, mo;
int w, ofs_x, ofs_y;
int item_this_day = 0;
- struct tm t = get_first_weekday(sunday_first);
+ struct tm t;
char *cp;
mo = slctd_day.mm;
@@ -380,7 +380,8 @@ draw_monthly_view(struct scrollwin *sw, struct date *current_day,
(int)((ymd_to_scalar(yr, mo, 1 + sunday_first) -
(long)1) % 7L);
- /* Print the week number. */
+ /* Print the week number, calculated from monday. */
+ t = get_first_weekday(0);
draw_week_number(sw, t);
/* Write the current month and year on top of the calendar */
@@ -468,17 +469,24 @@ draw_weekly_view(struct scrollwin *sw, struct date *current_day,
{
#define DAYSLICESNO 6
const int WCALWIDTH = 28;
- struct tm t = get_first_weekday(sunday_first);
+ struct tm t;
int OFFY, OFFX, j;
OFFY = 0;
OFFX = (wins_sbar_width() - 2 - WCALWIDTH) / 2;
- /* Print the week number. */
+ /* Print the week number, calculated from monday. */
+ t = get_first_weekday(0);
draw_week_number(sw, t);
/* Now draw calendar view. */
for (j = 0; j < WEEKINDAYS; j++) {
+ /* get next day */
+ if (j == 0)
+ t = get_first_weekday(sunday_first);
+ else
+ date_change(&t, 0, 1);
+
struct date date;
unsigned attr, item_this_day;
int i, slices[DAYSLICESNO];
@@ -554,9 +562,6 @@ draw_weekly_view(struct scrollwin *sw, struct date *current_day,
}
}
}
-
- /* get next day */
- date_change(&t, 0, 1);
}
/* Draw marks to indicate midday on the sides of the calendar. */