paskha.c revision 205821
1285SN/A/*- 2462SN/A * Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia. 3285SN/A * All rights reserved. 4285SN/A * 5285SN/A * Redistribution and use in source and binary forms, with or without 6285SN/A * modification, are permitted provided that the following conditions 7285SN/A * are met: 8285SN/A * 1. Redistributions of source code must retain the above copyright 9285SN/A * notice, this list of conditions and the following disclaimer. 10285SN/A * 2. Redistributions in binary form must reproduce the above copyright 11285SN/A * notice, this list of conditions and the following disclaimer in the 12285SN/A * documentation and/or other materials provided with the distribution. 13285SN/A * 14285SN/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 15285SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16285SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17285SN/A * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18285SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19285SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20285SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21285SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22285SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23285SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24285SN/A * SUCH DAMAGE. 25285SN/A */ 26285SN/A 27285SN/A#include <sys/cdefs.h> 28285SN/A__FBSDID("$FreeBSD: head/usr.bin/calendar/paskha.c 205821 2010-03-29 06:49:20Z edwin $"); 29285SN/A 30285SN/A#include <stdio.h> 31285SN/A#include <stdlib.h> 32285SN/A#include <string.h> 33285SN/A 34285SN/A#include "calendar.h" 35285SN/A 36285SN/A#define PASKHA "paskha" 37285SN/A#define PASKHALEN (sizeof(PASKHA) - 1) 38285SN/A 39285SN/A/* return year day for Orthodox Easter using Gauss formula */ 40285SN/A/* (old style result) */ 41285SN/A 42285SN/Aint 43285SN/Apaskha(int R) /*year*/ 44285SN/A{ 45285SN/A int a, b, c, d, e; 46285SN/A static int x = 15; 47285SN/A static int y = 6; 48285SN/A int *cumday; 49285SN/A 50285SN/A a = R % 19; 51285SN/A b = R % 4; 52285SN/A c = R % 7; 53285SN/A d = (19 * a + x) % 30; 54285SN/A e = (2 * b + 4 * c + 6 * d + y) % 7; 55285SN/A cumday = cumdaytab[isleap(R)]; 56285SN/A return (((cumday[3] + 1) + 22) + (d + e)); 57285SN/A} 58285SN/A