From 828a0d6589bad51e4fb41b41885a9c11fe0d0574 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Sat, 18 Jan 2020 14:52:17 -0500 Subject: [PATCH] Emit prevmonthyear and nextmonthyear items in -ppp format. --- man/rem2ps.1 | 8 ++++++++ src/calendar.c | 2 ++ tests/test.cmp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/man/rem2ps.1 b/man/rem2ps.1 index a5a5734b..fb120c28 100644 --- a/man/rem2ps.1 +++ b/man/rem2ps.1 @@ -616,12 +616,20 @@ The name of the previous month. .B daysinprevmonth \fIn\fR The number of days in the previous month. .TP +.B prevmonthyear \fIyyyy\fR +The year of the previous month. (The same as \fByear\fR unless the current +month is January.) +.TP .B nextmonthname \fIname\fR The name of the following month. .TP .B daysinnextmonth \fIn\fR The number of days in the following month. .TP +.B nextmonthyear \fIyyyy\fR +The year of the following month. (The same as \fByear\fR unless the +current month is December.) +.TP .B entries \fR[\fIarray\fR] The \fBentries\fR key consists of an array of calendar entries; each entry is a JSON object that has the same format as described in the diff --git a/src/calendar.c b/src/calendar.c index fa18622f..11146afd 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -501,6 +501,7 @@ static void DoCalendarOneMonth(void) } else { PrintJSONKeyPairString("prevmonthname", MonthName[mm]); PrintJSONKeyPairInt("daysinprevmonth", DaysInMonth(mm, yy)); + PrintJSONKeyPairInt("prevmonthyear", yy); } mm = m+1; if (mm>11) { @@ -511,6 +512,7 @@ static void DoCalendarOneMonth(void) } else { PrintJSONKeyPairString("nextmonthname", MonthName[mm]); PrintJSONKeyPairInt("daysinnextmonth", DaysInMonth(mm, yy)); + PrintJSONKeyPairInt("nextmonthyear", yy); printf("\"entries\":[\n"); } } diff --git a/tests/test.cmp b/tests/test.cmp index 2eeb9b40..02271067 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -4989,7 +4989,7 @@ February 29 -stdin-(7): Number too high [ { -"monthname":"January", "year":2012, "daysinmonth":31, "firstwkday":0, "mondayfirst":0, "daynames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"prevmonthname":"December", "daysinprevmonth":31, "nextmonthname":"February", "daysinnextmonth":29, "entries":[ +"monthname":"January", "year":2012, "daysinmonth":31, "firstwkday":0, "mondayfirst":0, "daynames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"prevmonthname":"December", "daysinprevmonth":31, "prevmonthyear":2011, "nextmonthname":"February", "daysinnextmonth":29, "nextmonthyear":2012, "entries":[ {"date":"2012-01-02", "filename":"-", "lineno":1, "d":2, "priority":5000, "body":"Normal"}, {"date":"2012-01-03", "filename":"-", "lineno":3, "passthru":"COLOR", "d":3, "priority":5000, "r":255, "g":0, "b":0, "rawbody":"Red", "body":"255 0 0 Red"}, {"date":"2012-01-04", "filename":"-", "lineno":5, "d":4, "priority":5000, "body":"Normal"}