Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH 1/4] cal: always include the year in the month header
@ 2018-01-25  0:51 J William Piggott
  2018-01-25  0:53 ` [PATCH 2/4] cal: remove year top header J William Piggott
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: J William Piggott @ 2018-01-25  0:51 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux


Most of cal's output has the year in the month header. The
exception is when a full year is output, which then has a top
header containing the year.

There is a bug when using --span with --year, --Year, or with
only a year for the date parameter; then months for multiple
years are output and only one year is displayed at the top.

These are all broken:
 cal -Sy 2020
 cal -SY 2020
 cal -S 2020
 cal -3 2020 (this is broken in the current release because it
	      too sets --span, but still displays 12 months)

The top header typically scrolls off the screen for a full
year output anyway. So it is convenient to have the year
included in each month.

To fix these issues and to make cal's output consistent,
always display the year in the month header.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
---
 misc-utils/cal.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 562ae2afb..8dea2c459 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -705,17 +705,16 @@ static void cal_output_header(struct cal_month *month, const struct cal_control
 	char out[FMT_ST_CHARS];
 	struct cal_month *i;
 
-	if (ctl->header_hint || ctl->header_year) {
+	if (ctl->header_hint) {
 		for (i = month; i; i = i->next) {
 			sprintf(out, _("%s"), ctl->full_month[i->month - 1]);
 			center(out, ctl->week_width - 1, i->next == NULL ? 0 : ctl->gutter_width);
 		}
-		if (!ctl->header_year) {
-			my_putstring("\n");
-			for (i = month; i; i = i->next) {
-				sprintf(out, _("%04d"), i->year);
-				center(out, ctl->week_width - 1, i->next == NULL ? 0 : ctl->gutter_width);
-			}
+		my_putstring("\n");
+		for (i = month; i; i = i->next) {
+			sprintf(out, _("%04d"), i->year);
+			center(out, ctl->week_width - 1,
+			       i->next == NULL ? 0 : ctl->gutter_width);
 		}
 	} else {
 		for (i = month; i; i = i->next) {

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-01-30 13:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-25  0:51 [PATCH 1/4] cal: always include the year in the month header J William Piggott
2018-01-25  0:53 ` [PATCH 2/4] cal: remove year top header J William Piggott
2018-01-30 11:08   ` Karel Zak
2018-01-30 12:21     ` Ruediger Meier
2018-01-30 13:38       ` Karel Zak
2018-01-25  1:02 ` [PATCH 3/4] cal: new top header to display the calendar system J William Piggott
2018-01-25 10:49   ` Ruediger Meier
2018-01-30 10:58   ` Karel Zak
2018-01-25  1:03 ` [PATCH 4/4] cal: new option to drop the calendar system header J William Piggott
2018-01-27  0:26   ` [v2 PATCH 4/4] cal: new option toggles " J William Piggott
2018-01-30 11:02     ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox