svn commit: r218797 - head/usr.bin/calendar

Sergey A. Osokin osa at FreeBSD.org
Fri Feb 18 13:41:45 UTC 2011


Author: osa (ports committer)
Date: Fri Feb 18 13:41:45 2011
New Revision: 218797
URL: http://svn.freebsd.org/changeset/base/218797

Log:
  Replace hard-coded value by Julian2Gregorian converter function.

Modified:
  head/usr.bin/calendar/calendar.h
  head/usr.bin/calendar/paskha.c

Modified: head/usr.bin/calendar/calendar.h
==============================================================================
--- head/usr.bin/calendar/calendar.h	Fri Feb 18 13:21:30 2011	(r218796)
+++ head/usr.bin/calendar/calendar.h	Fri Feb 18 13:41:45 2011	(r218797)
@@ -170,6 +170,7 @@ FILE	*opencal(void);
 /* ostern.c / paskha.c */
 int	paskha(int);
 int	easter(int);
+int	j2g(int);
 
 /* dates.c */
 extern int cumdaytab[][14];

Modified: head/usr.bin/calendar/paskha.c
==============================================================================
--- head/usr.bin/calendar/paskha.c	Fri Feb 18 13:21:30 2011	(r218796)
+++ head/usr.bin/calendar/paskha.c	Fri Feb 18 13:41:45 2011	(r218797)
@@ -36,6 +36,15 @@ __FBSDID("$FreeBSD$");
 #define	PASKHA		"paskha"
 #define	PASKHALEN	(sizeof(PASKHA) - 1)
 
+/* return difference in days between Julian and Gregorian calendars */
+int
+j2g(int year)
+{
+	return (year < 1500) ?
+		0 :
+		10 + (year/100 - 16) - ((year/100 - 16) / 4);
+}
+
 /* return year day for Orthodox Easter using Gauss formula */
 /* (new style result) */
 
@@ -53,5 +62,5 @@ paskha(int R) /*year*/
 	d = (19 * a + x) % 30;
 	e = (2 * b + 4 * c + 6 * d + y) % 7;
 	cumday = cumdaytab[isleap(R)];
-	return (((cumday[3] + 1) + 22) + (d + e) + 13);
+	return (((cumday[3] + 1) + 22) + (d + e) + j2g(R));
 }


More information about the svn-src-all mailing list