public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 03/10] cal: make day_in_week() use same variable names as other functions
Date: Sun, 27 Oct 2013 20:42:29 +0000	[thread overview]
Message-ID: <1382906556-16442-4-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1382906556-16442-1-git-send-email-kerolasa@iki.fi>

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/cal.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 720a548..f8e3714 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -259,7 +259,7 @@ static char *append_wnum(char *p, int *dp, int month, long year, int cal, int ro
 static void yearly(int day, long year, const struct cal_control *ctl);
 static void day_array(int day, int month, long year, int *days, const struct cal_control *ctl);
 static int day_in_year(int day, int month, long year);
-static int day_in_week(int d, int m, long y);
+static int day_in_week(int day, int month, long year);
 static int week_number(int day, int month, long year, const struct cal_control *ctl);
 static int week_to_day(long year, const struct cal_control *ctl);
 static char *ascii_day(char *p, int day, const struct cal_control *ctl);
@@ -819,7 +819,7 @@ static int day_in_year(int day, int month, long year)
  *	3 Sep. 1752 through 13 Sep. 1752, and returns invalid weekday
  *	during the period of 11 days.
  */
-static int day_in_week(int d, int m, long y)
+static int day_in_week(int day, int month, long year)
 {
 	static const int reform[] = {
 		SUNDAY, WEDNESDAY, TUESDAY, FRIDAY, SUNDAY, WEDNESDAY,
@@ -829,19 +829,19 @@ static int day_in_week(int d, int m, long y)
 		FRIDAY, MONDAY, SUNDAY, WEDNESDAY, FRIDAY, MONDAY,
 		WEDNESDAY, SATURDAY, TUESDAY, THURSDAY, SUNDAY, TUESDAY
 	};
-	if (y != 1753)
-		y -= m < 3;
+	if (year != 1753)
+		year -= month < 3;
 	else
-		y -= (m < 3) + 14;
-	if (REFORMATION_YEAR < y
-	    || (y == REFORMATION_YEAR && 9 < m)
-	    || (y == REFORMATION_YEAR && m == 9 && 13 < d))
-		return (y + (y / 4) - (y / 100) + (y / 400) + reform[m - 1] +
-			d) % 7;
-	if (y < REFORMATION_YEAR
-	    || (y == REFORMATION_YEAR && m < 9)
-	    || (y == REFORMATION_YEAR && m == 9 && d < 3))
-		return (y + y / 4 + old[m - 1] + d) % 7;
+		year -= (month < 3) + 14;
+	if (REFORMATION_YEAR < year
+	    || (year == REFORMATION_YEAR && 9 < month)
+	    || (year == REFORMATION_YEAR && month == 9 && 13 < day))
+		return (year + (year / 4) - (year / 100) + (year / 400) + reform[month - 1] +
+			day) % 7;
+	if (year < REFORMATION_YEAR
+	    || (year == REFORMATION_YEAR && month < 9)
+	    || (year == REFORMATION_YEAR && month == 9 && day < 3))
+		return (year + year / 4 + old[month - 1] + day) % 7;
 	return NONEDAY;
 }
 
-- 
1.8.4.1


  parent reply	other threads:[~2013-10-27 20:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-27 20:42 [0000/0010] cal: code revisit part I Sami Kerola
2013-10-27 20:42 ` [PATCH 01/10] cal: use control structure for run time configuration Sami Kerola
2013-10-31 11:29   ` Karel Zak
2013-10-27 20:42 ` [PATCH 02/10] cal: add input variable names to function prototypes Sami Kerola
2013-10-27 20:42 ` Sami Kerola [this message]
2013-10-27 20:42 ` [PATCH 04/10] cal: simplify ascii_wnum() function Sami Kerola
2013-10-27 20:42 ` [PATCH 05/10] cal: determine output width at beginning of run and reuse result Sami Kerola
2013-10-31 11:34   ` Karel Zak
2013-10-27 20:42 ` [PATCH 06/10] tests: cal: take account week numbers when determing month lenght Sami Kerola
2013-10-27 20:42 ` [PATCH 07/10] cal: make user request to be part of read-only control struct Sami Kerola
2013-10-31 11:49   ` Karel Zak
2013-11-01  9:29     ` Sami Kerola
2013-10-27 20:42 ` [PATCH 08/10] cal: determine how many header lines are needed at initialization Sami Kerola
2013-10-27 20:42 ` [PATCH 09/10] cal: add month contents structure Sami Kerola
2013-10-27 20:42 ` [PATCH 10/10] cal: make cal --three to use content structures Sami Kerola
2013-10-31 12:14 ` [0000/0010] cal: code revisit part I Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1382906556-16442-4-git-send-email-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox