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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Gregorian.pmod:81:    case 11: return ({y,m,30,305+year_leap_year(y)});    case 12: return ({y,m,31,335+year_leap_year(y)});    }       error("Month out of range.\n");   }      static array(int) month_from_yday(int y,int yd)   {   // [month,day-of-month,ndays,month-year-day] -  if (yd<1) return ({12,31+yd,32,335+year_leap_year(y-1)}); +  if (yd >= 1) {    int l=year_leap_year(y);    if (yd<32) return ({1,yd,31,1});    yd-=l;    switch (yd)    {    case 0..59: return ({2,yd-31+l,28+l,32}); -  case 60..90: return ({3,yd-59,31 ,60+year_leap_year(y)}); -  case 91..120: return ({4,yd-90,30 ,91+year_leap_year(y)}); -  case 121..151: return ({5,yd-120,31 ,121+year_leap_year(y)}); -  case 152..181: return ({6,yd-151,30 ,152+year_leap_year(y)}); -  case 182..212: return ({7,yd-181,31 ,182+year_leap_year(y)}); -  case 213..243: return ({8,yd-212,31 ,213+year_leap_year(y)}); -  case 244..273: return ({9,yd-243,30 ,244+year_leap_year(y)}); -  case 274..304: return ({10,yd-273,31,274+year_leap_year(y)}); -  case 305..334: return ({11,yd-304,30,305+year_leap_year(y)}); -  case 335..365: return ({12,yd-334,31,335+year_leap_year(y)}); +  case 60..90: return ({3,yd-59,31 ,60+l}); +  case 91..120: return ({4,yd-90,30 ,91+l}); +  case 121..151: return ({5,yd-120,31 ,121+l}); +  case 152..181: return ({6,yd-151,30 ,152+l}); +  case 182..212: return ({7,yd-181,31 ,182+l}); +  case 213..243: return ({8,yd-212,31 ,213+l}); +  case 244..273: return ({9,yd-243,30 ,244+l}); +  case 274..304: return ({10,yd-273,31,274+l}); +  case 305..334: return ({11,yd-304,30,305+l}); +  case 335..365: return ({12,yd-334,31,335+l});    } -  +  }    error("yday out of range.\n");   }      static array(int) week_from_julian_day(int jd)   {   // [year,week,day-of-week,ndays,week-julian-day]       [int y,int yjd]=year_from_julian_day(jd);    int yday=jd-yjd+1;   
pike.git/lib/modules/Calendar.pmod/Gregorian.pmod:192:    if (what->is_day)    {    int yd=what->yd;    if (yd>=55)    switch (year_leap_year(what->y)*10+year_leap_year(y))    {    case 00:    case 11:    break;    case 10: /* from leap to non-leap */ -  if (yd==55 && !force) return 0; // not this year +  if (yd==55) { +  if (!force) return 0; // not this year +  break; +  }    yd--;    break;    case 01: /* from non-leap to leap */    yd++;    break;    }    return Day("ymd_yd",rules,y,yjd,yjd+yd-1,yd,what->n);    }    -  return ::place(what); +  return ::place(what, force);    }   }      class cDay   {    inherit YMD::cDay;       int number_of_months()    {    if (n<=1) return 1;
pike.git/lib/modules/Calendar.pmod/Gregorian.pmod:241:    TimeRange place(TimeRange what,int|void force)    {    if (what->is_day)    {    int wmd=what->month_day();    if (md==CALUNKNOWN) make_month();    if (what->m==2 && m==2 && wmd>=24)    {    int l1=year_leap_year(what->y);    int l2=year_leap_year(y); -  if (l1||l2) +  if (l1 != l2)    { -  if (l1 && wmd==24) -  if (l2) wmd=24; -  else { if (!force) return 0; } +  if (l1) { +  if (wmd>24) wmd--; +  else if (wmd==24) { +  if (!force) return 0; +  } +  }    else    { -  if (l1 && wmd>24) wmd--; -  if (l2 && wmd>24) wmd++; +  if (wmd>24) wmd++;    }    }    }    if (!force && wmd>number_of_days()) return 0;    return Day("ymd_yd",rules,y,yjd,jd+wmd-1,yd+wmd-1,what->n);    }    -  return ::place(what); +  return ::place(what, force);    }   }      class cWeek   {    inherit YMD::cWeek;       string nice_print()    {    mixed err=catch