Update of /cvsroot/stack/stack-dev/lib
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28438/lib
Modified Files:
stringUtil.php error.php
Log Message:
Merging 2.2 branch
(with some additional fixes to ensure seamless updating for version lines)
Index: error.php
===================================================================
RCS file: /cvsroot/stack/stack-dev/lib/error.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** error.php 11 Jan 2010 17:23:36 -0000 1.22
--- error.php 30 Sep 2010 16:56:19 -0000 1.23
***************
*** 18,23 ****
*/
/**
! Error class
! Class for indicating and defining errors
*/
global $config;
--- 18,23 ----
*/
/**
! * Error class
! * Class for indicating and defining errors
*/
global $config;
Index: stringUtil.php
===================================================================
RCS file: /cvsroot/stack/stack-dev/lib/stringUtil.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** stringUtil.php 11 Jan 2010 17:23:36 -0000 1.20
--- stringUtil.php 30 Sep 2010 16:56:19 -0000 1.21
***************
*** 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;
+ }
}
|