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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Event.pmod:148:    constant NODAY=-1;       int nd=1;      // find the next (or same) jd with the event    int scan_jd(Calendar realm,int jd,int(1..1)|int(-1..-1) direction);      // find    TimeRange next(TimeRange from,void|int(0..1) including)    { -  int jd=(int)(from->julian_day())+!including; -  jd=scan_jd(from->calendar(),jd,1); -  if (jd==NODAY) return 0; +  int jd; +  if (including) jd=(int)(from->julian_day()); +  else jd=(int)(from->end()->julian_day()); +  jd=scan_jd(from->calendar(),jd-nd+1,1);    return (from->calendar()->Day)("julian_r",jd,from->ruleset())*nd;    }       TimeRange previous(TimeRange from,void|int(0..1) including)    { -  float|int jd=from->julian_day(); -  if (floatp(jd)) jd=(int)ceil(jd); -  if (!including) jd--; -  jd=scan_jd(from->calendar(),jd,-1); +  int jd; +  if (including) jd=(int)(from->end()->julian_day()); +  else jd=(floatp(from->julian_day()) +  ?(int)floor(from->julian_day()) +  :(from->julian_day()-1)); +  jd=scan_jd(from->calendar(),jd+nd-1,-1);    if (jd==NODAY) return 0;    return (from->calendar()->Day)("julian_r",jd,from->ruleset())*nd;    }   }         //! module Calendar   //! submodule Event   //! subclass Nameday   //! This is created by the <ref>Namedays</ref> classes
pike.git/lib/modules/Calendar.pmod/Event.pmod:439:    int md,mn;    int yd;       void create(string _name,int(1..31) _md,int(1..12) _mn,int ... _n)    {    name=_name;    md=_md;    mn=_mn;       yd=M_YD[mn]+md; - // if (sizeof(_n)) nd=_n[0]; -  nd=1; +  if (sizeof(_n)) nd=_n[0];    }       int scan_jd(Calendar realm,int jd,int(-1..1) direction)    {    [int y,int yjd,int leap]=gregorian_yjd(jd);    int njd;    -  +  for (;;) +  {    if (leap && yd>59)    njd=yjd+yd;    else    njd=yjd+yd-1; // yd start with 1       if (direction==1)    {    if (njd>=jd) return njd; -  return scan_jd(realm,yjd+365+leap,1); +  [y,yjd,leap]=gregorian_year(y+1);    } -  +  else +  {    if (njd<=jd) return njd; -  return scan_jd(realm,yjd-1,-1); +  [y,yjd,leap]=gregorian_year(y-1);    } -  +  } +  }       string describe()    {    return sprintf("%s %2d",M_NAME[mn],md);    }   }      // same, but julian   class Julian_Fixed   {