Branch: Tag:

2000-08-01

2000-08-01 09:22:15 by Mirar (Pontus Hagland) <pike@sort.mirar.org>

more then one day in a fixed date fix

Rev: lib/modules/Calendar.pmod/Event.pmod:1.2

155:   // 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;    }
446:    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)
455:    [int y,int yjd,int leap]=gregorian_yjd(jd);    int njd;    +  for (;;) +  {    if (leap && yd>59)    njd=yjd+yd;    else
463:    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()    {