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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Event.pmod:40:   //! from the given timerange's <b>start</b>,   //! including any event occuring at the start if that flag is set.   //!   //! It returns zero if there is no next event.   //!   //! This method is virtual in the base class.      class Event   {    string name; +  string id="?";       constant is_event=1;       TimeRange next(TimeRange from,void|int(0..1) including);    TimeRange previous(TimeRange from,void|int(0..1) including);      // what events in this period?    array(TimeRange) scan(TimeRange in)    {    array res=({});
pike.git/lib/modules/Calendar.pmod/Event.pmod:76:    {    with-=({0});    with|=({this_object()});    if (sizeof(with)==1) return with[0];    return SuperEvent(with);    }    Event ``|(Event with) { return `|(with); }       string _sprintf(int t)    { -  return (t!='O')?0:sprintf("Event(%s)",name); +  return (t!='O')?0:sprintf("Event(%s:%O)",id,name);    }       array(Event) cast(string to)    {    if (to[..4]=="array")    return ({this_object()});    else    error("Can't cast to %O\n",to);    }   
pike.git/lib/modules/Calendar.pmod/Event.pmod:99:    return "Unknown event";    }   }      class NullEvent   {    inherit Event;       constant is_nullevent=1;    -  void create(mixed ...args) {} +  void create(string _id,string s,mixed ...args) +  { +  id=_id; +  name=s; +  }       TimeRange next(TimeRange from,void|int(0..1) including)    {    return 0;    }       TimeRange previous(TimeRange from,void|int(0..1) including)    {    return 0;    }
pike.git/lib/modules/Calendar.pmod/Event.pmod:199:    }       int scan_jd(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)    { -  return t=='O'?sprintf("Nameday(%s)",name):0; +  return t=='O'?sprintf("Nameday(%s:%O)",id,name):0;    }   }      //! module Calendar   //! submodule Event   //! subclass Namedays   //! This contains a ruleset about namedays. It   //! is a virtual base class.   //! inherits Event   
pike.git/lib/modules/Calendar.pmod/Event.pmod:356:    }       TimeRange previous(TimeRange from,void|int(0..1) including)    {    return from->calendar()    ->Day("julian_r",(int)(from->julian_day()),from->ruleset());    }       string _sprintf(int t)    { -  return t=='O'?sprintf("Namedays(%s)",name):0; +  return t=='O'?sprintf("Namedays(%s:%O)",id,name):0;    }       string describe()    {    return "Namedays";    }   }         // ----------------------------------------------------------------
pike.git/lib/modules/Calendar.pmod/Event.pmod:437:   // used for the gregorian fixed events in the events list   class Gregorian_Fixed   {    inherit Day_Event;       constant is_fixed=1;       int md,mn;    int yd;    -  void create(string _name,int(1..31) _md,int(1..12) _mn,int ... _n) +  void create(string _id,string _name, +  int(1..31) _md,int(1..12) _mn,int ... _n)    { -  +  id=_id;    name=_name;    md=_md;    mn=_mn;       yd=M_YD[mn]+md;    if (sizeof(_n)) nd=_n[0];    }       int scan_jd(Calendar realm,int jd,int(-1..1) direction)    {
pike.git/lib/modules/Calendar.pmod/Event.pmod:730:   //! not the <ref>Gregorian</ref> or <ref>Julian</ref>   //! calendar that has 1=Sunday, 7=Saturday.      class Weekday   {    inherit Day_Event;    constant is_weekday=1;       int jd_wd;    -  void create(int wd) +  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 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:851:   // Easter relative      class Easter_Relative   {    inherit Easter;       constant is_easter_relative=1;       int offset;    -  void create(string _name,void|int _offset) +  void create(string _id,string _name,void|int _offset)    { -  +  id=_id;    name=_name;    offset=_offset;    }       int scan_jd(Calendar realm,int jd,int(-1..1) direction)    {    return offset+::scan_jd(realm,jd-direction*offset,direction);    }       string describe()
pike.git/lib/modules/Calendar.pmod/Event.pmod:881:   // simple set shift year very high      class Orthodox_Easter_Relative   {    inherit Easter_Relative;       constant is_orthodox_easter_relative=1;       int offset;    -  void create(string _name,void|int _offset) +  void create(string _id,string _name,void|int _offset)    { -  ::create(_name,_offset); +  ::create(_id,_name,_offset);    shift=9999999;    }   }      // Monthday Weekday relative,   // n:th special weekday,   // "fourth sunday before 24 dec" => md=24,mn=12,wd=7,n=-4      class Monthday_Weekday_Relative   {    inherit Gregorian_Fixed;       constant is_fixed=0;    constant is_monthday_weekday_relative=1;       int offset;    int wd;       int n,inclusive;    -  void create(string name,int(1..31) md,int(1..12) mn, +  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(name,md,mn); +  ::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;    else if (n>0)    offset=n*7-!!inclusive;    else
pike.git/lib/modules/Calendar.pmod/Event.pmod:977:   class SuperEvent   {    inherit Event;       constant is_superevent=1;    string name="SuperEvent";       mapping(Event:multiset(string)) flags=([]);       array(Event) events=({}); +  mapping(string:Event) id2event=([])[0];       array(Event) day_events=({});    array(Namedays) namedays=({});    array(Event) other_events=({});    -  mapping year_cache=([]); +        static void create(array(Event) _events, -  void|mapping(Event:multiset(string)) _flags) +  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)    {    events|=e->events;    if (flags[e] && flags[e]!=(<>))    foreach (e->events,Event e2)    flags[e2]=flags[e]|(e->flags[e2]||(<>));    else
pike.git/lib/modules/Calendar.pmod/Event.pmod:1024:   //! red in the calendar (non-working days),   //! Flagdays (flag "f") are the days that the flag   //! should be visible in (only some countries).       SuperEvent filter_flag(string flag)    {    array res=({});    multiset m;    foreach (events,Event e)    if ((m=flags[e]) && m[flag]) res+=({e}); -  return SuperEvent(res,flags&res); +  return SuperEvent(res,flags&res,id+"!"+flag);    }       SuperEvent holidays() { return filter_flag("h"); }    SuperEvent flagdays() { return filter_flag("f"); }       mapping(TimeRange:Event) scan_events(TimeRange in)    {    mapping res=([]);    foreach (events,Event e)    {
pike.git/lib/modules/Calendar.pmod/Event.pmod:1075:    TimeRange y=e->previous(from,including);    if (!best || best->preceeds(y)) best=y;    else if (y->ends_with(best)) best|=y;    }    return best;    }       Event `|(Event ... with)    {    with-=({0}); -  return SuperEvent(events|with,flags); +  return SuperEvent(events|with,flags,"?");    }    Event ``|(Event with) { return `|(with); }       Event `-(Event ...subtract)    {    array(Event) res=events-subtract;    if (res==events) return this_object(); -  return SuperEvent(res,flags&res); +  return SuperEvent(res,flags&res,"?");    }       array(Event) cast(string to)    {    if (to[..4]=="array")    return events;    else    error("Can't cast to %O\n",to);    }       string _sprintf(int t)    {    return (t!='O')?0:    (sizeof(events)>5 -  ? sprintf("SuperEvent(%O,%O..%O [%d])", -  events[0],events[1],events[-1], +  ? sprintf("SuperEvent(%s:%O,%O..%O [%d])", +  id,events[0],events[1],events[-1],    sizeof(events)) -  : sprintf("SuperEvent(%s)", -  map(events,lambda(Event e) { return sprintf("%O",e); })* +  : sprintf("SuperEvent(%s:%s)", +  id,map(events,lambda(Event e) { return sprintf("%O",e); })*    ","));    } -  +  +  function(string:Event) `-> = `[]; +  Event `[](string s) +  { +  if (!id2event) id2event=mkmapping(events->id,events); +  return +  ::`[](s) || +  id2event[id+"/"+s] || id2event[s] || +  master()->resolv("Calendar")["Events"][id+"/"+s];    }    -  +  array(string) _indices() +  { +  if (!id2event) id2event=mkmapping(events->id,events); +  return indices(id2event); +  } +  +  array(Event) _values() +  { +  if (!id2event) id2event=mkmapping(events->id,events); +  return values(id2event); +  } + } +