1*d19ef5a2SAaron LI /*- 2*d19ef5a2SAaron LI * SPDX-License-Identifier: BSD-3-Clause 3*d19ef5a2SAaron LI * 4*d19ef5a2SAaron LI * Copyright (c) 2020 The DragonFly Project. All rights reserved. 5*d19ef5a2SAaron LI * 6*d19ef5a2SAaron LI * This code is derived from software contributed to The DragonFly Project 7*d19ef5a2SAaron LI * by Aaron LI <aly@aaronly.me> 8*d19ef5a2SAaron LI * 9*d19ef5a2SAaron LI * Redistribution and use in source and binary forms, with or without 10*d19ef5a2SAaron LI * modification, are permitted provided that the following conditions 11*d19ef5a2SAaron LI * are met: 12*d19ef5a2SAaron LI * 13*d19ef5a2SAaron LI * 1. Redistributions of source code must retain the above copyright 14*d19ef5a2SAaron LI * notice, this list of conditions and the following disclaimer. 15*d19ef5a2SAaron LI * 2. Redistributions in binary form must reproduce the above copyright 16*d19ef5a2SAaron LI * notice, this list of conditions and the following disclaimer in 17*d19ef5a2SAaron LI * the documentation and/or other materials provided with the 18*d19ef5a2SAaron LI * distribution. 19*d19ef5a2SAaron LI * 3. Neither the name of The DragonFly Project nor the names of its 20*d19ef5a2SAaron LI * contributors may be used to endorse or promote products derived 21*d19ef5a2SAaron LI * from this software without specific, prior written permission. 22*d19ef5a2SAaron LI * 23*d19ef5a2SAaron LI * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24*d19ef5a2SAaron LI * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25*d19ef5a2SAaron LI * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26*d19ef5a2SAaron LI * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27*d19ef5a2SAaron LI * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28*d19ef5a2SAaron LI * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 29*d19ef5a2SAaron LI * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30*d19ef5a2SAaron LI * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 31*d19ef5a2SAaron LI * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32*d19ef5a2SAaron LI * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 33*d19ef5a2SAaron LI * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34*d19ef5a2SAaron LI * SUCH DAMAGE. 35*d19ef5a2SAaron LI */ 36*d19ef5a2SAaron LI 37*d19ef5a2SAaron LI #ifndef DAYS_H_ 38*d19ef5a2SAaron LI #define DAYS_H_ 39*d19ef5a2SAaron LI 40*d19ef5a2SAaron LI /* IDs of special days */ 41*d19ef5a2SAaron LI enum { 42*d19ef5a2SAaron LI SD_NONE, 43*d19ef5a2SAaron LI SD_EASTER, 44*d19ef5a2SAaron LI SD_PASKHA, 45*d19ef5a2SAaron LI SD_ADVENT, 46*d19ef5a2SAaron LI SD_CNY, 47*d19ef5a2SAaron LI SD_CQINGMING, 48*d19ef5a2SAaron LI SD_CJIEQI, 49*d19ef5a2SAaron LI SD_MAREQUINOX, 50*d19ef5a2SAaron LI SD_SEPEQUINOX, 51*d19ef5a2SAaron LI SD_JUNSOLSTICE, 52*d19ef5a2SAaron LI SD_DECSOLSTICE, 53*d19ef5a2SAaron LI SD_NEWMOON, 54*d19ef5a2SAaron LI SD_FULLMOON, 55*d19ef5a2SAaron LI }; 56*d19ef5a2SAaron LI 57*d19ef5a2SAaron LI struct cal_day; 58*d19ef5a2SAaron LI 59*d19ef5a2SAaron LI struct specialday { 60*d19ef5a2SAaron LI int id; /* enum ID of the special day */ 61*d19ef5a2SAaron LI const char *name; /* name of the special day */ 62*d19ef5a2SAaron LI size_t len; /* length of the name */ 63*d19ef5a2SAaron LI char *n_name; /* national name of the special day */ 64*d19ef5a2SAaron LI size_t n_len; /* length of the national name */ 65*d19ef5a2SAaron LI 66*d19ef5a2SAaron LI /* function to find days of the special day in [rd1, rd2] */ 67*d19ef5a2SAaron LI int (*find_days)(int offset, struct cal_day **dayp, char **edp); 68*d19ef5a2SAaron LI }; 69*d19ef5a2SAaron LI 70*d19ef5a2SAaron LI extern struct specialday specialdays[]; 71*d19ef5a2SAaron LI 72*d19ef5a2SAaron LI int find_days_ymd(int year, int month, int day, 73*d19ef5a2SAaron LI struct cal_day **dayp, char **edp); 74*d19ef5a2SAaron LI int find_days_dom(int dom, struct cal_day **dayp, char **edp); 75*d19ef5a2SAaron LI int find_days_month(int month, struct cal_day **dayp, char **edp); 76*d19ef5a2SAaron LI int find_days_mdow(int month, int dow, int index, 77*d19ef5a2SAaron LI struct cal_day **dayp, char **edp); 78*d19ef5a2SAaron LI 79*d19ef5a2SAaron LI #endif 80