123925Sgibbs/*- 223925Sgibbs * Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia. 323925Sgibbs * All rights reserved. 423925Sgibbs * 523925Sgibbs * Redistribution and use in source and binary forms, with or without 623925Sgibbs * modification, are permitted provided that the following conditions 723925Sgibbs * are met: 823925Sgibbs * 1. Redistributions of source code must retain the above copyright 923925Sgibbs * notice, this list of conditions and the following disclaimer. 1023925Sgibbs * 2. Redistributions in binary form must reproduce the above copyright 1126997Sgibbs * notice, this list of conditions and the following disclaimer in the 1254211Sgibbs * documentation and/or other materials provided with the distribution. 1339220Sgibbs * 1423925Sgibbs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 1523925Sgibbs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1623925Sgibbs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1723925Sgibbs * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1823925Sgibbs * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1923925Sgibbs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2023925Sgibbs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2123925Sgibbs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2223925Sgibbs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2323925Sgibbs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2423925Sgibbs * SUCH DAMAGE. 2523925Sgibbs */ 2623925Sgibbs 2723925Sgibbs#include <sys/cdefs.h> 2850477Speter__FBSDID("$FreeBSD$"); 2923925Sgibbs 3023925Sgibbs#include <stdio.h> 3123925Sgibbs#include <stdlib.h> 3223925Sgibbs#include <string.h> 3323925Sgibbs 3423925Sgibbs#include "calendar.h" 3523925Sgibbs 3623925Sgibbs#define PASKHA "paskha" 3723925Sgibbs#define PASKHALEN (sizeof(PASKHA) - 1) 3823925Sgibbs 3923925Sgibbs/* return difference in days between Julian and Gregorian calendars */ 4023925Sgibbsint 4123925Sgibbsj2g(int year) 4229897Sgibbs{ 4323925Sgibbs return (year < 1500) ? 4423925Sgibbs 0 : 4523925Sgibbs 10 + (year/100 - 16) - ((year/100 - 16) / 4); 4623925Sgibbs} 4723925Sgibbs 4823925Sgibbs/* return year day for Orthodox Easter using Gauss formula */ 4923925Sgibbs/* (new style result) */ 5023925Sgibbs 5123925Sgibbsint 5223925Sgibbspaskha(int R) /*year*/ 5323925Sgibbs{ 5423925Sgibbs int a, b, c, d, e; 5523925Sgibbs static int x = 15; 5623925Sgibbs static int y = 6; 5723925Sgibbs int *cumday; 5823925Sgibbs 5923925Sgibbs a = R % 19; 6023925Sgibbs b = R % 4; 6160938Sjake c = R % 7; 6223925Sgibbs d = (19 * a + x) % 30; 6323925Sgibbs e = (2 * b + 4 * c + 6 * d + y) % 7; 6423925Sgibbs cumday = cumdaytab[isleap(R)]; 6523925Sgibbs return (((cumday[3] + 1) + 22) + (d + e) + j2g(R)); 6623925Sgibbs} 6723925Sgibbs