Roxen.git
/
server
/
etc
/
modules
/
Variable.pmod
/
Schedule.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:38:
//! @value 0 //! Day //! @value 1 //! Sunday //! @value 2..7 //! Rest of weekdays //! @endint //! @elem int(0..23) time (z) //! Time at which to restart. //! @endarray
-
array transform_from_form( string what,
void|
mapping vl )
+
array transform_from_form( string what, mapping vl )
{ array res = query() + ({}); if(sizeof(res)!=5) res = ({ 0, 2, 1, 6, 3 }); res[0] = (int)what; for(int i=1; i<5; i++) { res[i] = (int)vl[(string)i]; res[i] = max( ({ 0, 1, 1, 0, 0 })[i], res[i] ); res[i] = min( ({ 2, 23, 9, 7, 23 })[i], res[i] );
Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:61:
return res; } private string checked( int pos, int alt ) { if(alt==query()[pos]) return " checked='checked'"; return ""; }
-
private mapping next_or_same_day(mapping from, int day)
+
private mapping next_or_same_day(mapping from, int day
, int hour
)
{
-
if(from->wday==day) return from;
+
if(from->wday==day
&& from->hour<hour
)
+
return from;
return next_day(from, day); } private mapping next_day(mapping from, int day) { from->hour = 0; if(from->wday<day) { return localtime(mktime(from) + (day - from->wday)*3600*24); } return localtime(mktime(from) + (7 - from->wday + day)*3600*24);
Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:108:
//! values < time() essentially means go ahead and do it right away. //! Minutes and seconds are cleared in the return value, so if the scheduler //! is set to every day at 5 o'clock, and this method is called at 5:42 it //! will return the posix time representing 5:00, unless of course @[last] //! was set to a posix time >= 5:00. //! Returns @tt{-1@} if the schedule is disabled (@tt{"Never"@}). { array vals = query(); if( !vals[0] ) return -1;
+
+
// Every n:th hour.
if( vals[0] == 1 ) if( !last ) return time(1); else return last + 3600 * vals[1];
-
+
// Every n:th day at x.
mapping m = localtime( last || time(1) ); m->min = m->sec = 0; if( !vals[3] ) {
-
+
// Every day at x.
for(int i; i<vals[2]; i++) m = next_or_same_time( m, vals[4] ); return mktime(m); } for(int i; i<vals[2]; i++) {
-
m = next_or_same_time( next_or_same_day( m, vals[3]-1 ),
+
m = next_or_same_time( next_or_same_day( m, vals[3]-1
,
vals[4]
),
vals[4], 6*24*3600 ); } return mktime(m); } string render_form( RequestID id, void|mapping additional_args ) { string res, inp1, inp2, inp3; res = "<table>"
Roxen.git/server/etc/modules/Variable.pmod/Schedule.pike:175:
{ array res = query(); switch(res[0]) { case 0: return LOCALE(482, "Never"); case 1: return sprintf(LOCALE(493, "Every %d hour."), res[1]); case 2: string period = ({ LOCALE(484, "Day"),
+
LOCALE(485, "Sunday"),
LOCALE(486, "Monday"), LOCALE(487, "Tuesday"), LOCALE(488, "Wednesday"), LOCALE(489, "Thursday"), LOCALE(490, "Friday"),
-
LOCALE(491, "Saturday")
,
-
LOCALE(485, "Sunday")
+
LOCALE(491, "Saturday")
})[query()[3]]; return sprintf(LOCALE(494, "Every %d %s at %02d:00"), res[2], period, res[4]); default: return LOCALE(495, "Error in stored value."); } }