pike.git / lib / modules / Calendar.pmod / Discordian.pmod

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Discordian.pmod:22:   //! - Mirar, Pope of POEE.      // the discordian calendar follows the gregorian years, very practical ;)      inherit Calendar.Gregorian:Gregorian;      #include "constants.h"      string calendar_name() { return "Discordian"; }    - private static mixed __initstuff=lambda() + private protected mixed __initstuff=lambda()   {   // language setup    f_week_day_shortname_from_number=    "discordian_week_day_shortname_from_number";    f_week_day_name_from_number="discordian_week_day_name_from_number";    f_year_name_from_number="discordian_year_name_from_number";    f_month_name_from_number="discordian_month_name_from_number";    f_month_shortname_from_number="discordian_month_shortname_from_number";    f_month_number_from_name="discordian_month_number_from_name";    f_week_name_from_number="discordian_week_name_from_number";    f_week_day_number_from_name="discordian_week_day_number_from_name";   }();    - static int compat_week_day(int n) + protected int compat_week_day(int n)   {    return n; // N/A   }      // almost as gregorian - static array year_from_julian_day(int jd) + protected array year_from_julian_day(int jd)   {    array a=::year_from_julian_day(jd);    return ({a[0]+1166,a[1]});   }    - static int julian_day_from_year(int y) + protected int julian_day_from_year(int y)   {    return ::julian_day_from_year(y-1166);   }    - static int year_leap_year(int y) + protected int year_leap_year(int y)   {    return ::year_leap_year(y-1166);   }    - static array(int) year_month_from_month(int y,int m) + protected array(int) year_month_from_month(int y,int m)   {   // [y,m,ndays,myd]       y+=(m-1)/5;    m=1+(m-1)%5;       switch (m)    {    case 1: return ({y,m,73+year_leap_year(y),1});    case 2..5: return ({y,m,73,1+73*(m-1)+year_leap_year(y)});    }       error("month out of range\n");   }    - static array(int) month_from_yday(int y,int yd) + protected array(int) month_from_yday(int y,int yd)   {   // [month,day-of-month,ndays,month-year-day]    int l=year_leap_year(y);       if (yd<=73+l) return ({1,yd,73+l,1});    yd-=l;    int m=(yd+72)/73;    return ({m,yd-(m-1)*73,73,(m-1)*73+l+1});   }    - static array(int) week_from_julian_day(int jd) + protected array(int) week_from_julian_day(int jd)   {   // [year,week,day-of-week,ndays,week-julian-day]       [int y,int yjd]=year_from_julian_day(jd);    int yday=jd-yjd+1;    int l=year_leap_year(y);       if (l)    if (yday==60)    return ({y,12,6,6,yjd+55});
pike.git/lib/modules/Calendar.pmod/Discordian.pmod:107:    return ({y,12,(yday==61)?5:yday-55,6,yjd+55});    else if (yday>60)    yday--;    else    l=0;       int w=(yday+4)/5;    return ({y,w,(yday-1)%5+1,5,yjd+(w-1)*5+l});   }    - static array(int) week_from_week(int y,int w) + protected array(int) week_from_week(int y,int w)   {   // [year,week,1 (wd),ndays,week-julian-day]    y+=(w-1)/73;    w=1+(w-1)%73;    int yjd=julian_day_from_year(y);       int l=year_leap_year(y);    if (!l||w<12) return ({y,w,1,5,yjd+(w-1)*5});    return week_from_julian_day(yjd+(w-1)*5+(l&&w>12));   }    - static int year_remaining_days(int y,int yday) + protected int year_remaining_days(int y,int yday)   {    return 365+year_leap_year(y)-yday;   }      class cYear   {    inherit Gregorian::cYear;       int number_of_weeks()    {
pike.git/lib/modules/Calendar.pmod/Discordian.pmod:230:    }       return ::place(what);    }   }      class cWeek   {    inherit Gregorian::cWeek;    -  static int weeks_to_week(int y2,int w2) +  protected int weeks_to_week(int y2,int w2)    {    return (y2-y)*73+w2-w;    }       int number_of_days()    {    [int y2,int w2,int wd2,int nd2,int jd2]=week_from_week(y,w+n);    return jd2-jd;    }   }