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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Event.pmod:1:   #pike __REAL_VERSION__    - static constant M_YD=({0,0,31,59,90,120,151,181,212,243,273,304,334}); - static constant M_ED=({({0,31,59,90,120,151,181,212,243,273,304,334,365}), + protected constant M_YD=({0,0,31,59,90,120,151,181,212,243,273,304,334}); + protected constant M_ED=({({0,31,59,90,120,151,181,212,243,273,304,334,365}),    ({0,31,60,91,121,152,182,213,244,274,305,335,366}),    ({0,31,60,90,120,151,181,212,243,273,304,334,365}) }); - static constant M_NAME="---JanFebMarAprMayJunJulAugSepOctNovDec"/3; - static constant WD_NAME="---MonTueWedThuFriSatSun"/3; + protected constant M_NAME="---JanFebMarAprMayJunJulAugSepOctNovDec"/3; + protected constant WD_NAME="---MonTueWedThuFriSatSun"/3;    - static function(mixed...:Calendar.TimeRanges.TimeRange) std_day= + protected function(mixed...:Calendar.TimeRanges.TimeRange) std_day=    Calendar.Day; - static function(mixed...:Calendar.TimeRanges.TimeRange) std_second= + protected function(mixed...:Calendar.TimeRanges.TimeRange) std_second=    Calendar.Second;      // ----------------------------------------------------------------   // base classes   // ----------------------------------------------------------------         //! Event is an abstract class, defining what methods an Event   //! need to have.   class Event
pike.git/lib/modules/Calendar.pmod/Event.pmod:315:    [Calendar.TimeRanges.TimeRange t,array(string) s])    res[t]=predef::`|(@map(s,Nameday,t->julian_day()));    return res;    }       array(Calendar.TimeRanges.TimeRange) scan(Calendar.TimeRanges.TimeRange in)    {    return indices(namedays(in));    }    -  static Calendar.TimeRanges.TimeRange _find(Calendar.TimeRanges.TimeRange t, +  protected Calendar.TimeRanges.TimeRange _find(Calendar.TimeRanges.TimeRange t,    int including, int direction)    {    int jd=(int)t->julian_day();       jd+=direction*!including;       [int y,int yjd,int leap]=gregorian_yjd(jd);    int ld;    if (y<leapdayshift) ld=55-1; // 24 feb    else ld=60-1; // 29 feb
pike.git/lib/modules/Calendar.pmod/Event.pmod:491:    if (e->is_namedays && e->id==id)    return SuperNamedays(namedayss|({e}),id);    return predef::`|(e,this,@extra);    }   }      // ----------------------------------------------------------------   // simple Gregorian date events   // ----------------------------------------------------------------    - static array gregorian_yjd(int jd) + protected array gregorian_yjd(int jd)   {    int d=jd-1721426;       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;       int y=century*100+century_year+1;       return    ({    y,    1721426+century_year*365+century_year/4+century_jd,    (!(((y)%4) || (!((y)%100) && ((y)%400))))    });   }    - static array gregorian_year(int y) + protected array gregorian_year(int y)   {    return    ({    y,    1721426+(y-1)*365+(y-1)/4-(y-1)/100+(y-1)/400,    (!(((y)%4) || (!((y)%100) && ((y)%400))))    });   }    - static array julian_yjd(int jd) + protected array julian_yjd(int jd)   {    int d=jd-1721058;       int quad=d/1461;    int quad_year=max( (d%1461-1)/365, 0);       int y=quad*4+quad_year;       return    ({    y,    1721424+(y-1)*365+(y-1)/4,    !(y%4),    });   }    - static array julian_year(int y) + protected array julian_year(int y)   {    return    ({    y,    1721424+(y-1)*365+(y-1)/4,    !(y%4),    });   }      //! A set date of year, counting leap day in February,
pike.git/lib/modules/Calendar.pmod/Event.pmod:864:    int shift=1582;       //! @decl void create(void|int shift)    //! @[shift] is the year to shift from old to new style easter    //! calculation. Default is 1582.    void create(void|int _shift)    {    if (_shift) shift=_shift;    }    -  static int new_style(int y) +  protected int new_style(int y)    {    int century=y/100;    int solar=century-century/4;    int lunar=(century-15-(century-17)/25)/3;    int epact=(13+11*(y%19)-solar+lunar)%30;   // if (epact<0) epact+=30; // not neccesary for pike    int new_moon=31-epact;   // werror("epact: %O\n",epact);   // werror("new_moon: %O\n",new_moon);    if (new_moon<8)    if (epact==24 || epact==25 && (y%19)>10)    new_moon+=29;    else    new_moon+=30;    int full_moon=new_moon+13;    int week_day=(2+y+y/4-solar+full_moon)%7;    return full_moon+7-week_day;    }    -  static int old_style(int y) +  protected int old_style(int y)    {   #if 1    int new_moon=23-11*(y%19);    while (new_moon<8) new_moon+=30;    int full_moon=new_moon+13;    int week_day=(y+y/4+full_moon)%7;    return full_moon+7-week_day;   #else    int g=y%19;    int i=(19*g+15)%30;
pike.git/lib/modules/Calendar.pmod/Event.pmod:911:   #endif    }       //! Calculates the year day for the easter.    int easter_yd(int y,int yjd,int leap)    {    int z=(y<shift)?old_style(y):new_style(y);    return `+(yjd,z,58,leap);    }    -  static array(int) my_year(int y) +  protected array(int) my_year(int y)    {    if (y<shift) return julian_year(y);    return gregorian_year(y);    }       int scan_jd(Calendar.Calendar realm,int jd,int(-1..1) direction)    {    int y,yjd,leap,ejd;      // werror("scan %O %O\n",jd,direction);
pike.git/lib/modules/Calendar.pmod/Event.pmod:1086:    mapping(Event:multiset(string)) flags=([]);       array(Event) events=({});    mapping(string:Event) id2event=UNDEFINED;       array(Event) day_events=({});    array(Namedays) namedays=({});    array(Event) other_events=({});       -  static void create(array(Event) _events, +  protected void create(array(Event) _events,    void|mapping(Event:multiset(string)) _flags,    void|string _id)    {    if (_id) id=_id;       if (_flags) flags=_flags;       foreach (_events,Event e)    if (e->is_superevent)    {
pike.git/lib/modules/Calendar.pmod/Event.pmod:1267:    }    Calendar.TimeRanges.TimeRange previous(void|Calendar.TimeRanges.TimeRange from,    void|int(0..1) including)    {    if (!from) from=std_second();    return scan_shift(timezone||from->timezone(),    from,-1,including);    }       //! -  static Calendar.TimeRanges.TimeRange +  protected Calendar.TimeRanges.TimeRange    scan_shift(Calendar.Rule.Timezone tz,    Calendar.TimeRanges.TimeRange from,    int direction,int including)    {    if (tz->whatrule)    return scan_history(tz,from,direction,including);    return scan_rule(tz,from,direction,including);    }       //! -  static Calendar.TimeRanges.TimeRange +  protected Calendar.TimeRanges.TimeRange    scan_history(Calendar.Rule.Timezone tz,    Calendar.TimeRanges.TimeRange from,    int direction,int(0..1) including)    {    int ux;       if ((direction==1) ^ (!!including))    ux=(from=from->end())->unix_time();    else    ux=from->unix_time();
pike.git/lib/modules/Calendar.pmod/Event.pmod:1327:    return atr;    if (!atr)    return btr;    if ( (direction==1)^(btr>atr) )    return btr;    else    return atr;    }       //! -  static Calendar.TimeRanges.TimeRange +  protected Calendar.TimeRanges.TimeRange    scan_rule(Calendar.Rule.Timezone tz,    Calendar.TimeRanges.TimeRange from,    int direction,int including)    {    if (!tz->jd_year_periods)    return 0; // non-shifting timezone       int jd;    if ((direction==1) ^ (!!including))    jd=(int)(from=from->end())->julian_day();