Roxen.git / server / etc / modules / Variable.pmod / Schedule.pike

version» Context lines:

Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:68:   private mapping next_or_same_day(mapping from, int day)   {    if(from->wday==day) return from;    return next_day(from, day);   }      private mapping next_day(mapping from, int day)   {    from->hour = 0;    if(from->wday<day) { -  from->wday = day; -  return from; +  return localtime(mktime(from) + (day - from->wday)*3600*24);    } -  return localtime(mktime(from) + (7-from->wday)*3600*24 + day*3600*24); +  return localtime(mktime(from) + (7 - from->wday + day)*3600*24);   }      private mapping next_or_same_time(mapping from, int hour, void|int delta)   {    if(from->hour==hour) return from;    return next_time(from, hour, delta);   }      private mapping next_time(mapping from, int hour, void|int delta)   {    if(from->hour<hour) {    from->hour = hour;    return from;    } -  return localtime(mktime(from) + (24-from->hour)*3600 + delta + hour*3600); +  return localtime(mktime(from) + (24 - from->hour + hour)*3600 + delta);   }      int get_next( int last )   //! Get the next time that matches this schedule, starting from the   //! posix time @[last]. If last is 0, time(1) will be used instead.   //!   //! @returns   //! When the next scheduled event is, represented by a posix time integer.   //! Note that the returnes time may already have occured, so all return   //! values < time() essentially means go ahead and do it right away.
Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:113:    if( !vals[0] )    return -1;    if( vals[0] == 1 )    if( !last )    return time(1);    else    return last + 3600 * vals[1];       mapping m = localtime( last || time(1) );    m->min = m->sec = 0; -  if( !last ) -  { -  if( !vals[3] ) -  return mktime( next_or_same_time( m, vals[4] ) ); -  return mktime( next_or_same_time( -  next_or_same_day( m, vals[3]-1 ), -  vals[4], 7*24*3600 ) ); +  if( !vals[3] ) { +  for(int i; i<vals[2]; i++) +  m = next_or_same_time( m, vals[4] ); +  return mktime(m);    } -  -  m->hour = 0; -  if(!vals[3]) -  return mktime(m)+vals[2]*24*3600 + vals[4]*3600; +     for(int i; i<vals[2]; i++) -  m = next_day(m, vals[3]-1); -  return mktime(m) + vals[4]*3600; +  { +  m = next_or_same_time( next_or_same_day( m, vals[3]-1 ), +  vals[4], 6*24*3600 );    } -  +  return mktime(m); + }      string render_form( RequestID id, void|mapping additional_args )   {    string res, inp1, inp2, inp3;       res = "<table>"    "<tr valign='top'><td><input name='" + path() + "' value='0' type='radio' " +    checked(0,0) + " /></td><td>" + LOCALE(482, "Never") + "</td></tr>\n";       inp1 = select(path()+"1", "123456789"/1 + "1011121314151617181920212223"/2, (string)query()[1]);