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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Event.pmod:75:    //! Joins several events into one @[SuperEvent].    SuperEvent `|(Event ... with)    {    with-=({0});    with|=({this});    if (sizeof(with)==1) return with[0];    return SuperEvent(with);    }    SuperEvent ``|(Event with) { return `|(with); }    -  string _sprintf(int t) +  protected string _sprintf(int t)    {    return (t!='O')?0:sprintf("Event(%s:%O)",id,name);    }       array(Event) cast(string to)    {    if (to[..4]=="array")    return ({this});    else    error("Can't cast to %O\n",to);
pike.git/lib/modules/Calendar.pmod/Event.pmod:213:    name=_name;    jd=_jd;    }       int scan_jd(Calendar.Calendar realm,int sjd,int(1..1)|int(-1..-1) direction)    {    if (direction==1) return sjd<=jd?jd:NODAY;    else return sjd>=jd?jd:NODAY;    }    -  string _sprintf(int t) +  protected string _sprintf(int t)    {    return t=='O'?sprintf("Nameday(%s:%O)",id,name):0;    }   }      //! This contains a ruleset about namedays.   class Namedays   {    inherit Event;   
pike.git/lib/modules/Calendar.pmod/Event.pmod:375:    {    return _find(from,including,1);    }       Calendar.TimeRanges.TimeRange previous(Calendar.TimeRanges.TimeRange from,    void|int(0..1) including)    {    return _find(from,including,-1);    }    -  string _sprintf(int t) +  protected string _sprintf(int t)    {    return t=='O'?sprintf("Namedays(%s:%O)",id,name):0;    }       string describe()    {    return "Namedays";    }       SuperEvent|SuperNamedays|Namedays
pike.git/lib/modules/Calendar.pmod/Event.pmod:404:    array a=({e})|({this});    if (!sizeof(a)) res=this;    else if (e->is_namedays && e->id==id) res=SuperNamedays(a,id);    else res=SuperEvent(a);    }    if (sizeof(extra)) return predef::`|(res,@extra);    return res;    }   }    - //! Container for merged @[Namedays] objects. - class SuperNamedays + //! Container for merged @[Namedays] objects. Presumes non-overlapping + //! namedays + class SuperNamedays (array(Nameday) namedayss, string id)   {    inherit Event;    constant is_namedays_wrapper=1;    - // presumed non-overlapping namedays -  array(Nameday) namedayss; -  string id; -  -  void create(array(Nameday) _namedays,string _id) +  protected string _sprintf(int t)    { -  name=id=_id; -  namedayss=_namedays; +  return t=='O' && sprintf("SuperNamedays(%s [%d])",id,sizeof(namedayss));    }    -  string _sprintf(int t) -  { -  return t=='O'?sprintf("SuperNamedays(%s [%d])",id,sizeof(namedayss)):0; -  } -  +     string describe()    {    return "Namedays";    }       array(Calendar.TimeRanges.TimeRange) scan(Calendar.TimeRanges.TimeRange in)    {    return indices(namedays(in));    }   
pike.git/lib/modules/Calendar.pmod/Event.pmod:566:    inherit Day_Event;       //! This constant may be used to identify @[Gregorian_Fixed] objects.    constant is_fixed=1;       int md,mn;    int yd;       //! @decl void create(string id, string name, int(1..31) month_day,@    //! int(1..12) month, int extra) -  void create(string _id,string _name, -  int(1..31) _md,int(1..12) _mn,int ... _n) +  protected void create(string id, string name, +  int(1..31) month_day, int(1..12) month, +  int ... extra)    { -  id=_id; -  name=_name; -  md=_md; -  mn=_mn; +  this_program::id=id; +  this_program::name=name; +  md=month_day; +  mn=month;       yd=M_YD[mn]+md; -  if (sizeof(_n)) nd=_n[0]; +  if (sizeof(extra)) nd=extra[0];    }       int scan_jd(Calendar.Calendar realm,int jd,int(-1..1) direction)    {    [int y,int yjd,int leap]=gregorian_yjd(jd);    int njd;       for (;;)    {    if (leap && yd>59)
pike.git/lib/modules/Calendar.pmod/Event.pmod:664:   {    inherit Day_Event;       int md,mn;       int yd;       //! @decl void create(int(1..31) month_day, int(1..12) month)    //! The event is created by a given month day and a month number    //! (1=January, 12=December). -  void create(int _md,int _mn) +  protected void create(int _md,int _mn)    {    md=_md;    mn=_mn;    name=M_NAME[mn]+" "+md;       yd=M_YD[mn]+md;    }       int scan_jd(Calendar.Calendar realm,int jd,int(-1..1) direction)    {
pike.git/lib/modules/Calendar.pmod/Event.pmod:720:       //! @decl void create(int month_day, int month, int weekday)    //! The event is created by a given month day,    //! a month number (1=January, 12=December), and a    //! weekday number (1=Monday, 7=Sunday).    //!    //! @note    //! The week day numbers used are the same as the day of week in    //! the @[ISO] calendar - the @[Gregorian] calendar has 1=Sunday,    //! 7=Saturday. -  void create(int _md,int _mn,int wd) +  protected void create(int _md,int _mn,int wd)    {    md=_md;    mn=_mn;    name=M_NAME[mn]+" "+md+" "+WD_NAME[wd];       yd=M_YD[mn]+md;    jd_wd=(wd+6)%7;    }       int scan_jd(Calendar.Calendar realm,int jd,int(-1..1) direction)
pike.git/lib/modules/Calendar.pmod/Event.pmod:776:    int jd_wd;       //! @decl void create(int month_day,int weekday)    //! The event is created by a given month day,    //! and a weekday number (1=Monday, 7=Sunday).    //!    //! @note    //! The week day numbers used are the same as the day of week in    //! the @[ISO] calendar - the @[Gregorian] calendar has 1=Sunday,    //! 7=Saturday. -  void create(int _md,int wd) +  protected void create(int _md,int wd)    {    md=_md;    name=md+","+WD_NAME[wd];    jd_wd=(wd+6)%7;    }       int scan_jd(Calendar.Calendar realm,int jd,int(-1..1) direction)    {    if (md>31 || md<1) return 0;    [int y,int yjd,int leap]=gregorian_yjd(jd);
pike.git/lib/modules/Calendar.pmod/Event.pmod:837:       int jd_wd;       //! @decl void create(int weekday, void|string id)    //! The event is created by a given weekday number (1=Monday, 7=Sunday).    //!    //! @note    //! The week day numbers used are the same as the day of week in    //! the @[ISO] calendar - the @[Gregorian] calendar has 1=Sunday,    //! 7=Saturday. -  void create(int wd,void|string _id) +  protected void create(int wd,void|string _id)    {    jd_wd=(wd+6)%7; // convert to julian day numbering    name=WD_NAME[wd];    if (!id) id=name; else id=_id;    }       int scan_jd(Calendar.Calendar realm,int jd,int(-1..1) direction)    {    if (direction==-1) return jd-(jd-jd_wd)%7;    return jd+(7-(jd-jd_wd))%7;
pike.git/lib/modules/Calendar.pmod/Event.pmod:1029:    [int new_jd, float offset] = solar_event(y);       if ((direction > 0) && (new_jd < jd)) {    [new_jd, offset] = solar_event(y + 1);    } else if ((direction < 0) && (new_jd >= jd)) {    [new_jd, offset] = solar_event(y - 1);    }       // Convert into an UTC timestamp.    int utc = (new_jd - 2440588)*86400 + (int)(offset * 86400.0); -  return utc - (int)round(Calendar.ISO.deltat(utc)); +  return utc - (int)round(.ISO.deltat(utc));    }       Calendar.TimeRanges.TimeRange next(void|Calendar.TimeRanges.TimeRange from,    void|int(0..1) including)    {    if (!from) from=std_day();    int jd;    if (including) jd=(int)(from->julian_day());    else jd=(int)(from->end()->julian_day());    int utc = scan_jd(from->calendar(),jd-nd+1,1);
pike.git/lib/modules/Calendar.pmod/Event.pmod:1070:   //! This class represents an easter.   class Easter   {    inherit Day_Event;       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) +  protected void create(void|int _shift)    {    if (_shift) shift=_shift;    }       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;
pike.git/lib/modules/Calendar.pmod/Event.pmod:1168:   //! This class represents an easter relative event.   class Easter_Relative   {    inherit Easter;       constant is_easter_relative=1;       int offset;       //! @decl void create(string id, string name, int offset) -  void create(string _id,string _name,void|int _offset) +  protected void create(string _id,string _name,void|int _offset)    {    id=_id;    name=_name;    offset=_offset;    }       int scan_jd(Calendar.Calendar realm,int jd,int(-1..1) direction)    {    return offset+::scan_jd(realm,jd-direction*offset,direction);    }
pike.git/lib/modules/Calendar.pmod/Event.pmod:1198:   //! This class represents an orthodox easter relative event.   class Orthodox_Easter_Relative   {    inherit Easter_Relative;       constant is_orthodox_easter_relative=1;       int offset;       //! @decl void create(string id, string name, int offset) -  void create(string _id,string _name,void|int _offset) +  protected void create(string _id,string _name,void|int _offset)    {    ::create(_id,_name,_offset);    shift=9999999;    }   }      //! This class represents a monthday weekday relative event or   //! n:th special weekday event, e.g.   //! "fourth sunday before 24 dec" => md=24,mn=12,wd=7,n=-4   class Monthday_Weekday_Relative
pike.git/lib/modules/Calendar.pmod/Event.pmod:1221:       constant is_fixed=0;    constant is_monthday_weekday_relative=1;       int offset;    int wd;       int n,inclusive;       //! -  void create(string id,string name,int(1..31) md,int(1..12) mn, +  protected void create(string id,string name,int(1..31) md,int(1..12) mn,    int(1..7) _wd,int _n,void|int(0..1) _inclusive)    {    ::create(id,name,md,mn);       n=_n;    inclusive=_inclusive;      // offset is the offset to the last possible day    if (n<0)    offset=(n+1)*7-!inclusive;
pike.git/lib/modules/Calendar.pmod/Event.pmod:1413:    }       array(Event) cast(string to)    {    if (to[..4]=="array")    return events;    else    error("Can't cast to %O\n",to);    }    -  string _sprintf(int t) +  protected string _sprintf(int t)    {    return (t!='O')?0:    (sizeof(events)>5    ? sprintf("SuperEvent(%s:%O,%O..%O [%d])",    id,events[0],events[1],events[-1],    sizeof(events))    : sprintf("SuperEvent(%s:%s)",    id,map(events,lambda(Event e) { return sprintf("%O",e); })*    ","));    }
pike.git/lib/modules/Calendar.pmod/Event.pmod:1457:      //! Event containing information about when a timezone is changed.   class TZShift_Event   {    inherit Event;       constant is_tzshift_event=1;       Calendar.Rule.Timezone timezone;    -  void create(void|Calendar.Rule.Timezone _tz) +  protected void create(void|Calendar.Rule.Timezone _tz)    {    timezone=_tz;    }       Calendar.TimeRanges.TimeRange next(void|Calendar.TimeRanges.TimeRange from,    void|int(0..1) including)    {    if (!from) from=std_second();    return scan_shift(timezone||from->timezone(),    from,1,including);