From f218d6528d580c2c382bd59a33ba8f2e3477279d Mon Sep 17 00:00:00 2001 From: James Date: Thu, 26 Dec 2019 12:23:15 +0000 Subject: [PATCH] make rrule responsable only for managing date. comments are done by other scripts --- src/rrule.php | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/src/rrule.php b/src/rrule.php index 1e38d6c..9a9e451 100755 --- a/src/rrule.php +++ b/src/rrule.php @@ -3,9 +3,8 @@ /* * This will find all issues with RRULE: in the body * 1. extract the RRULE string and calculate the recurring dates. -* 2. if the rule is due to occure today then: -* 2a. if the issue is closed then it will re-open it, -* 2b. and it will add a comment "Today!" +* 2. if no due date then set the due date to the next occurance +* 3. if the issue is closed then repoen it and set the due date to the next occurance */ // load the config, create the connection and load the repo sepcified on the cmd line args @@ -15,11 +14,7 @@ require('setup.php'); use RRule\RRule; //function to add/replace the tag with our text -/* function updateIssueBody($issue,$text){ - $issue->addComment($text); - return; - // add a tag to the body if to doesn't exist if( strpos($issue->body,'')===false ){ $issue->body.="\n
"; @@ -28,7 +23,6 @@ function updateIssueBody($issue,$text){ $issue->body=preg_replace("#.*?#s",'
'.$text.'',$issue->body); $issue->save(); }; -*/ //loop through each issue that has a RRULE $issues=array_merge( @@ -60,37 +54,24 @@ foreach($issues as $issue){ $next_exc=$rrule->getOccurrencesAfter(date('Y-m-d'),$inclusive=false,$limit=1)[0]; $today=$next_inc->format('Y-m-d')==date('Y-m-d'); - if($debug){ - echo $rrule->humanReadable(). + $summary=$rrule->humanReadable(). "\n NOW: ".date('Y-m-d'). "\n First: ".$rrule[0]->format('Y-m-d'). "\n Second: ".$rrule[1]->format('Y-m-d'). + "\n Third: ".$rrule[2]->format('Y-m-d'). "\n Today: ".($today?'Yes':'no'). "\n Next Inc: ".$next_inc->format('Y-m-d'). "\n Next Exc: ".$next_exc->format('Y-m-d'). "\n"; + updateIssueBody($issue,str_replace("\n","
\n",$summary)); + + if( !$issue->due_date ){ + $issue->setDueDate($next_inc>format('c')); } - //is it today? - if($today){ - echo "@Today\n"; - if($issue->state=='closed'){ - $issue->state='open'; - $issue->save(); - } - $issue->addComment("Today!!\n\nNext: ".$next_exc->format('Y-m-d')); - } - - // not working https://github.com/go-gitea/gitea/issues/8179 - //$issue->due_date=$rrule[0]->format('c'); - //$issue->save(); - //if( date('Y-m-d',strtotime($issue->due_date)) != $next_exc->format('Y-m-d') ){ - if( $issue->due_date ){ - if( strtotime(date('Y-m-d',strtotime($issue->due_date))) < strtotime($next_exc->format('Y-m-d')) ){ - echo "@Overdue\n"; - $issue->addComment("Overdue!!\n\nNext: ".$next_exc->format('Y-m-d')); - } - }else{ - $issue->setDueDate($next_exc); + if($issue->state=='closed'){ + $issue->due_date=$next_exc->format('c'); + $issue->state='open'; + $issue->save(); } }