From: Simon H. <sim...@us...> - 2010-11-09 16:51:46
|
Update of /cvsroot/stack/stack-dev/lib In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv25193/lib Modified Files: Tag: item_state_separation stringUtil.php AimConverter.php error.php Log Message: Brought back up to date with big HEAD merge. Index: error.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/error.php,v retrieving revision 1.21 retrieving revision 1.21.8.1 diff -C2 -d -r1.21 -r1.21.8.1 *** error.php 27 Aug 2009 16:23:00 -0000 1.21 --- error.php 9 Nov 2010 16:51:38 -0000 1.21.8.1 *************** *** 18,23 **** */ /** ! Error class ! Class for indicating and defining errors */ global $config; --- 18,23 ---- */ /** ! * Error class ! * Class for indicating and defining errors */ global $config; *************** *** 30,34 **** private $fail; //bool if error has occured, should the program fail? private $userError; //array of errors for display to the user. format key=>errormessage ! private $logger; function __construct($fail=false) --- 30,34 ---- private $fail; //bool if error has occured, should the program fail? private $userError; //array of errors for display to the user. format key=>errormessage ! //private static $logger; function __construct($fail=false) *************** *** 37,41 **** $this->status = false; //no error yet $this->userError = array(); ! $this->logger = new Logger('ErrorLog'); } --- 37,41 ---- $this->status = false; //no error yet $this->userError = array(); ! //$this->logger = new Logger('ErrorLog'); } Index: AimConverter.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/AimConverter.php,v retrieving revision 1.6 retrieving revision 1.6.8.1 diff -C2 -d -r1.6 -r1.6.8.1 *** AimConverter.php 11 Sep 2009 08:43:55 -0000 1.6 --- AimConverter.php 9 Nov 2010 16:51:38 -0000 1.6.8.1 *************** *** 167,171 **** case "h": case "hide": ! $questionVariables .= "$text\n"; break; --- 167,184 ---- case "h": case "hide": ! // convert rand function ! $rand_pattern = '/:=rand\((-?\d+)\.\.(-?\d+)\)/'; ! preg_match($rand_pattern, $text, $matches); ! $lower = $matches[1]; ! $upper = $matches[2]; ! /* $questionVariables .= 'rand('.($upper-$lower).')'; // range ! if($lower != 0) { ! if($matches[1] > 0) echo '+'; ! echo $matches[1]; ! }*/ ! $text = preg_replace('/rand\('.$lower.'..'.$upper.'\)/', "rand_with_step($lower, $upper, 1)", $text); ! // change assignment operator ! $text = str_replace(':=', '=', $text); ! $questionVariables .= $text."\n"; break; Index: stringUtil.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/stringUtil.php,v retrieving revision 1.19.6.5 retrieving revision 1.19.6.5.2.1 diff -C2 -d -r1.19.6.5 -r1.19.6.5.2.1 *** stringUtil.php 5 Nov 2009 10:39:38 -0000 1.19.6.5 --- stringUtil.php 9 Nov 2010 16:51:38 -0000 1.19.6.5.2.1 *************** *** 584,587 **** --- 584,616 ---- return $array; } + + /** + * Returns a more intuitive datestamp + */ + public static function prettifyDate($datestamp) { + /* + * Rules: + * show time if this week + * show day + month if this year + * show month + year if not this year + */ + + $dayStart = strtotime("00:00"); + $monthAgo = strtotime('-1 month'); + $yearAgo = strtotime('-1 year'); + + //echo "yearstart: $yearStart monthStart: $monthStart dayStart: $dayStart"; + + $time = strtotime($datestamp); + + if($time >= $dayStart) return date("g:ia", $time);// today + if($time > $monthAgo) return date("g:ia, j M", $time);// not today + if($time > $yearAgo) return date("M Y", $time); // not this year + if($time > $yearAgo) return date("j M", $time); // not this month + + + // failed to prettify somehow + return $datestamp; + } } |