diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2024-08-18 19:58:36 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2024-08-18 19:58:36 +0000 |
commit | 716dfb4b086c44f011513fd9398e707e678ed4c9 (patch) | |
tree | 64be0533fd234c2ec5fe50c7ab116d3aedc5bd1a /usr.bin/cal | |
parent | 74f8858e255cadc4e432dfe3e72e456d28b2e54d (diff) |
whitespace
Diffstat (limited to 'usr.bin/cal')
-rw-r--r-- | usr.bin/cal/README | 4 | ||||
-rw-r--r-- | usr.bin/cal/cal.c | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/cal/README b/usr.bin/cal/README index 638ac9dffb6..83051657ee2 100644 --- a/usr.bin/cal/README +++ b/usr.bin/cal/README @@ -10,13 +10,13 @@ that even if I was dumb enough to try. From this we can easily calculate the day of week for any date. The algorithm for a zero based day of week: calculate the number of days in all prior years (year-1)*365 - add the number of leap years (days?) since year 1 + add the number of leap years (days?) since year 1 (not including this year as that is covered later) add the day number within the year this compensates for the non-inclusive leap year calculation if the day in question occurs before the gregorian reformation - (3 sep 1752 for our purposes), then simply return + (3 sep 1752 for our purposes), then simply return (value so far - 1 + SATURDAY's value of 6) modulo 7. if the day in question occurs during the reformation (3 sep 1752 to 13 sep 1752 inclusive) return THURSDAY. This is my diff --git a/usr.bin/cal/cal.c b/usr.bin/cal/cal.c index c37402dfd10..ea6c812d11e 100644 --- a/usr.bin/cal/cal.c +++ b/usr.bin/cal/cal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cal.c,v 1.31 2022/12/04 23:50:47 cheloha Exp $ */ +/* $OpenBSD: cal.c,v 1.32 2024/08/18 19:58:35 deraadt Exp $ */ /* $NetBSD: cal.c,v 1.6 1995/03/26 03:10:24 glass Exp $ */ /* @@ -261,7 +261,7 @@ week(int day, int month, int year) shift = 1; if (yearday < firstsunday) return (1); - if (firstweekday > THURSDAY - 1) + if (firstweekday > THURSDAY - 1) shift = 2; return ((((yearday + 1) - (weekday - 1)) / 7) + shift); } @@ -291,7 +291,7 @@ isoweek(int day, int month, int year) return 53 - (g - s) / 5; else if (n > 364 + s) return 1; - else + else return n/7 + 1; } |