ac8c922003-03-12Martin Nilsson #pike __REAL_VERSION__ //! This is the Coptic Orthodox Church calendar, //! that starts the 11th or 12th September and has
3524712015-05-26Martin Nilsson //! 13 months.
dc21d42001-05-05Mirar (Pontus Hagland) //!
ac8c922003-03-12Martin Nilsson //! @note //! The (default) names of the months //! are different then other the emacs calendar; //! I do not know which ones are used - the difference //! seem to be only the transcription of the phonetic sounds //! (B <-> P, etc).
78fd532000-07-12Mirar (Pontus Hagland) //!
ac8c922003-03-12Martin Nilsson //! I do not know for how long back the calendar is valid, //! either. My sources claim that the calendar is synchronized //! with the @[Gregorian] calendar, which is odd.
a20af62000-09-26Fredrik Hübinette (Hubbe) 
78fd532000-07-12Mirar (Pontus Hagland) // inherit some rules from Gregorian, like week numbering
9f0b6c2008-02-07Martin Stjernholm inherit Calendar.Gregorian:Gregorian;
78fd532000-07-12Mirar (Pontus Hagland)  string calendar_name() { return "Coptic"; }
9eaf1d2008-06-28Martin Nilsson private protected mixed __initstuff=lambda()
78fd532000-07-12Mirar (Pontus Hagland) { f_week_day_shortname_from_number="gregorian_week_day_shortname_from_number"; f_week_day_name_from_number="gregorian_week_day_name_from_number"; f_week_day_number_from_name="gregorian_week_day_number_from_name"; f_year_name_from_number="coptic_year_name_from_number"; f_month_name_from_number="coptic_month_name_from_number"; f_month_shortname_from_number="coptic_month_shortname_from_number"; f_month_number_from_name="coptic_month_number_from_name"; f_week_name_from_number="week_name_from_number"; }();
9eaf1d2008-06-28Martin Nilsson protected constant year_offset=-284; protected constant start=1720949;
78fd532000-07-12Mirar (Pontus Hagland) 
9eaf1d2008-06-28Martin Nilsson protected array year_from_julian_day(int jd)
78fd532000-07-12Mirar (Pontus Hagland) { int d=jd-start; int century=(4*d+3)/146097; int century_jd=(century*146097)/4; int century_day=d-century_jd; int century_year=(100*century_day+75)/36525;
3524712015-05-26Martin Nilsson  return
78fd532000-07-12Mirar (Pontus Hagland)  ({ century*100+century_year+year_offset, start+century_year*365+century_year/4+century_jd, }); }
9eaf1d2008-06-28Martin Nilsson protected int julian_day_from_year(int y)
78fd532000-07-12Mirar (Pontus Hagland) { y-=year_offset; return start+y*365+y/4-y/100+y/400; }
3524712015-05-26Martin Nilsson protected int year_leap_year(int y) {
78fd532000-07-12Mirar (Pontus Hagland)  y-=year_offset; werror("%O\n",y); return (!(((y)%4) || (!((y)%100) && ((y)%400)))); }
9eaf1d2008-06-28Martin Nilsson protected array(int) year_month_from_month(int y,int m)
78fd532000-07-12Mirar (Pontus Hagland) { // [y,m,ndays,myd] y+=(m-1)/13; m=1+(m-1)%13; return ({y,m,m==13?year_leap_year(y)+5:30,1+30*(m-1)}); }
9eaf1d2008-06-28Martin Nilsson protected array(int) month_from_yday(int y,int yd)
78fd532000-07-12Mirar (Pontus Hagland) { // [month,day-of-month,ndays,month-year-day] int m=(yd-1)/30+1; int myd=1+30*(m-1); return ({m,1+yd-myd,m==13?year_leap_year(y)+5:30,myd}); } class cYear { inherit Gregorian::cYear; int number_of_months() { return 13*n; } }