diff options
Diffstat (limited to 'usr.bin/calendar')
-rw-r--r-- | usr.bin/calendar/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/calendar/calendar.h | 7 | ||||
-rw-r--r-- | usr.bin/calendar/calendars/calendar.judaic | 41 | ||||
-rw-r--r-- | usr.bin/calendar/day.c | 19 | ||||
-rw-r--r-- | usr.bin/calendar/pesach.c | 66 |
5 files changed, 103 insertions, 34 deletions
diff --git a/usr.bin/calendar/Makefile b/usr.bin/calendar/Makefile index ed9214b09ab..9c479dc697a 100644 --- a/usr.bin/calendar/Makefile +++ b/usr.bin/calendar/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.8 2004/01/16 18:43:28 mickey Exp $ +# $OpenBSD: Makefile,v 1.9 2004/12/10 20:47:30 mickey Exp $ PROG= calendar -SRCS= calendar.c io.c day.c ostern.c paskha.c +SRCS= calendar.c io.c day.c pesach.c ostern.c paskha.c INTER= de_DE.ISO_8859-1 hr_HR.ISO_8859-2 ru_RU.KOI8-R fr_FR.ISO8859-1 beforeinstall: diff --git a/usr.bin/calendar/calendar.h b/usr.bin/calendar/calendar.h index f5ff7db8e05..7024cc22bec 100644 --- a/usr.bin/calendar/calendar.h +++ b/usr.bin/calendar/calendar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: calendar.h,v 1.10 2004/12/10 15:00:27 mickey Exp $ */ +/* $OpenBSD: calendar.h,v 1.11 2004/12/10 20:47:30 mickey Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -75,6 +75,7 @@ int getday(char *); int getdayvar(char *); int getfield(char *, char **, int *); int getmonth(char *); +int pesach(int); int easter(int); int paskha(int); void insert(struct event **, struct event *); @@ -100,6 +101,8 @@ extern int f_dayBefore; /* days before current date */ /* Special events; see also setnnames() in day.c */ /* '=' is not a valid character in a special event name */ +#define PESACH "pesach" +#define PESACHLEN (sizeof(PESACH) - 1) #define EASTER "easter" #define EASTERNAMELEN (sizeof(EASTER) - 1) #define PASKHA "paskha" @@ -109,7 +112,7 @@ extern int f_dayBefore; /* days before current date */ extern enum calendars { GREGORIAN = 0, JULIAN, LUNAR } calendar; extern u_long julian; -#define NUMEV 2 /* Total number of such special events */ +#define NUMEV 3 /* Total number of such special events */ extern struct specialev spev[NUMEV]; /* For calendar -a, specify a maximum time (in seconds) to spend parsing diff --git a/usr.bin/calendar/calendars/calendar.judaic b/usr.bin/calendar/calendars/calendar.judaic index f1512796bb5..21d7b88d5a8 100644 --- a/usr.bin/calendar/calendars/calendar.judaic +++ b/usr.bin/calendar/calendars/calendar.judaic @@ -1,39 +1,36 @@ /* * Judaic * - * $OpenBSD: calendar.judaic,v 1.3 2003/01/06 05:51:06 mickey Exp $ + * $OpenBSD: calendar.judaic,v 1.4 2004/12/10 20:47:30 mickey Exp $ */ #ifndef _calendar_judaic_ #define _calendar_judaic_ -03/08* Fast of Esther (Battle of Purim; 1 day before Purim; fast day) -03/11* Purim (Feast of Lots; 30 days before Pesach) -03/12* Purim (Feast of Lots) -04/10* Pesach (First Day of Passover; sabbatical) -04/11* Pesach (sabbatical) -04/16* Pesach (sabbatical) -04/17* Pesach (Last Day of Passover; 8th day of Pesach; sabbatical) +Pesach-31 Fast of Esther (Battle of Purim; fast day) +Pesach-30 Purim (Feast of Lots) +Pesach-29 Purim (Feast of Lots) +Pesach Pesach (First Day of Passover; sabbatical) +Pesach+1 Pesach (sabbatical) +Pesach+6 Pesach (sabbatical) +Pesach+7 Pesach (Last Day of Passover; 8th day of Pesach; sabbatical) 05/13* Lag Ba`omer (Commemoration of the Great Rebellion) 05/22* Yom Yerushalayim (Reunification of Jerusalem) -05/30* Shavuos (Festival of Weeks; 50 days after Pesach; sabbatical) -05/31* Shavuos (Festival of Weeks; sabbatical) +Pesach+50 Shavuos (Festival of Weeks; sabbatical) +Pesach+51 Shavuos (Festival of Weeks; sabbatical) 07/10* Fast of Shiv'a Asar B'Tammuz (Romans breach Wall of Jerusalem; fast day) 07/31* Fast of Tish'a B'Av (Babylon/Rome destroys Holy Temple; fast day) -09/20* First Day of Rosh Hashanah (Jewish Lunar New Year; 5741 == 1980; +Pesach+163 First Day of Rosh Hashanah (Jewish Lunar New Year; 5741 == 1980; sabbatical) -09/21* Rosh Hashanah (sabbatical) -09/23* Fast of Gedalya (Murder of Gedalya and subsequent Exile; 1 day - after Rosh Hashanah; fast day) -09/29* Yom Kippur (Day of Atonement; 9 days after Rosh Hashanah; - sabbatical, fast day) -10/04* Succos (Festival of Tabernacles; 14 days after Rosh Hashanah; - sabbatical) -10/05* Succos (sabbatical) -10/10* Hoshanah Rabba (7th day of Succos) -10/11* Shmini Atzeres (8th Day of Gathering; 1 day after Succos; sabbatical) -10/12* Shmini Atzeres/Simchas Torah (Rejoicing of the Law; sabbatical) +Pesach+164 Rosh Hashanah (sabbatical) +Pesach+166 Fast of Gedalya (Murder of Gedalya and subsequent Exile; fast day) +Pesach+172 Yom Kippur (Day of Atonement; sabbatical, fast day) +Pesach+178 Succos (Festival of Tabernacles; sabbatical) +Pesach+179 Succos (sabbatical) +Pesach+184 Hoshanah Rabba (7th day of Succos) +Pesach+185 Shmini Atzeres (8th Day of Gathering; sabbatical) +Pesach+186 Shmini Atzeres/Simchas Torah (Rejoicing of the Law; sabbatical) 12/12* First Day of Chanukah 12/27* Fast of Asara B'Tevet (Babylonians put siege on Jerusalem; fast day) diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c index 0bf255d0f9d..07b216c1223 100644 --- a/usr.bin/calendar/day.c +++ b/usr.bin/calendar/day.c @@ -1,4 +1,4 @@ -/* $OpenBSD: day.c,v 1.17 2004/12/10 15:31:01 mickey Exp $ */ +/* $OpenBSD: day.c,v 1.18 2004/12/10 20:47:30 mickey Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -39,7 +39,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; #else -static const char rcsid[] = "$OpenBSD: day.c,v 1.17 2004/12/10 15:31:01 mickey Exp $"; +static const char rcsid[] = "$OpenBSD: day.c,v 1.18 2004/12/10 20:47:30 mickey Exp $"; #endif #endif /* not lint */ @@ -143,12 +143,15 @@ void setnnames(void) fnmonths[i].len = strlen(buf); } /* Hardwired special events */ - spev[0].name = strdup(EASTER); - spev[0].nlen = EASTERNAMELEN; - spev[0].getev = easter; - spev[1].name = strdup(PASKHA); - spev[1].nlen = PASKHALEN; - spev[1].getev = paskha; + spev[0].name = strdup(PESACH); + spev[0].nlen = PESACHLEN; + spev[0].getev = pesach; + spev[1].name = strdup(EASTER); + spev[1].nlen = EASTERNAMELEN; + spev[1].getev = easter; + spev[2].name = strdup(PASKHA); + spev[2].nlen = PASKHALEN; + spev[2].getev = paskha; for (i = 0; i < NUMEV; i++) { if (spev[i].name == NULL) err(1, NULL); diff --git a/usr.bin/calendar/pesach.c b/usr.bin/calendar/pesach.c new file mode 100644 index 00000000000..0851b9b17ab --- /dev/null +++ b/usr.bin/calendar/pesach.c @@ -0,0 +1,66 @@ +/* $OpenBSD: pesach.c,v 1.1 2004/12/10 20:47:30 mickey Exp $ */ + +/* + * Copyright (c) 2004 Michael Shalayeff + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <stdio.h> +#include <tzfile.h> + +#include "calendar.h" + +/* Calculate the Julian date of Pesach using the Gauss formula */ + +#define T (33. + 14. / 24.) +#define L ((1. + 485. / 1080.) / 24. / 19.) +#define K ((29. + (12. + 793. / 1080.) / 24. ) / 19.) + +int +pesach(int R) +{ + int a, b, y, cumdays; + double d; + + y = R + 3760; + + a = (12 * y + 17) % 19; + b = y % 4; + d = (T - 10 * K + L + 14) + K * a + b / 4. - L * y; + cumdays = d; + + /* the postponement */ + switch ((int)(cumdays + 3 * y + 5 * b + 5) % 7) { + case 1: + if (a > 6 && d - cumdays >= (15. + 204. / 1080.) / 24.) + cumdays += 2; + break; + + case 0: + if (a <= 11 || d - cumdays < (21. + 589. / 1080.) / 24.) + break; + /* FALLTHROUGH */ + case 2: + case 4: + case 6: + cumdays++; + break; + } + + if (R > 1582) + cumdays += R / 100 - R /400 - 2; + + return (31 + 28 + cumdays + (isleap(R)? 1 : 0)); +} |