Below is a change I’d like to make to asyncservices.
I ask because I think it has little or no value to anyone besides
myself, but it will help me out a lot.
It adds the ability to find out the next run time as at a given date
instead of just “now”
Example use:
$times = Array ( [month] => * [day] => * [dow] => * [hour] => * [min]
=> */5 );
$next_run = ExecMethod2(‘phpgwapi.asyncservice.next_run’, $times);
echo date(‘Y-m-d H:i’, $next_run); // Gives 2009-06-25 13:40 when
called between 13:35 and 13:39
$next_run = ExecMethod2(‘phpgwapi.asyncservice.next_run’, $times,
false, mktime(9,23,0,7,1,2009));
echo date(‘Y-m-d H:i’, $next_run); // Gives 2009-07-01 09:25, always
Previous functionality is not changed. If there are no major
objections, I’ll commit this to trunk.
Index: class.asyncservice.inc.php
— class.asyncservice.inc.php (revision 27268)
+++ class.asyncservice.inc.php (working copy)
@@ -97,16 +97,19 @@
* for every 5mins in the time from 9am to 5pm. All not set units
before the smallest one set,
* are taken into account as every possible value, all after as
the smallest possible value.
* @param boolean $debug if True some debug-messages about syntax-
errors in $times are echoed
-
-
@param int $now Use this time to calculate then next run from.
Defaults to time().
-
@return int a unix timestamp of the next execution time or False
if no more executions
*/
- function next_run($times,$debug=False)
- function next_run($times,$debug=False, $now = null)
{
if ($this->debug)
{
m-d H:i’, $now) . “)
\n”;
$debug = True; // enable syntax-error messages too
}
False
//
@@ -257,7 +260,7 @@
foreach($units as $u => $date_pattern)
{
-
$unit_now = $u != 'dow' ? (int)date($date_pattern, $now) :
(int)date($date_pattern,mktime(12,0,0,$found['month'],
$found[‘day’],$found[‘year’]));
if (isset($found[$u]))
eGroupWare-developers mailing list
eGroupWare-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-developers