sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit f02f2190f064584ff838352a8ec1cc92dc191742
parent 5721deb2c4b5dffa87f9ee481831882eb02dc7c8
Author: Willem van de Krol <008054@jfc.nl>
Date:   Fri Jul  4 22:23:52 +0200

fixed incorrect fday handling in dayofweek() function

Diffstat:
cal.c | 14+++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/cal.c b/cal.c @@ -79,15 +79,11 @@ drawcal(int year, int month, int day, int ncols, int nmons, int fday) static int dayofweek(int year, int month, int day, int fday) { - int a, y, m, d; - - month++; - a = (14 - month) / 12; - y = year + 4800 - a; - m = month + 12 * a - 3; - d = (day + (153 * m + 2) / 5 + 365 * y + y / 4 - y / 100 + y \ - / 400 - 32045 + 1) % 7; - return (fday > d)? (7 - d) : (d - fday); + static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; + + day += 7 - fday; + year -= month < 2; + return (year + year / 4 - year / 100 + year / 400 + t[month] + day) % 7; } static bool