public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
* Added "relative" Twig filter for relative time representation.
* relative_time's first arg can now be a strtotime()'able value.
vito (author)
Thu Nov 13 17:01:13 -0800 2008
commit  63711b58155ffb3a983c53886b64adabd1b7f7ea
tree    9164f4663dc369ebe46c1e2418927806b561de58
parent  372e77c4f2ba61ae9a718d29e525fc76d2952a14
...
18
19
20
 
21
22
23
...
18
19
20
21
22
23
24
0
@@ -18,6 +18,7 @@ $twig_filters = array(
0
     'moneyformat' =>       'money_format',
0
     'filesizeformat' =>    'twig_filesize_format_filter',
0
     'format' =>            'sprintf',
0
+    'relative' =>          'relative_time',
0
 
0
     // numbers
0
     'even' =>              'twig_is_even_filter',
...
1504
1505
1506
1507
 
 
 
1508
1509
1510
...
1504
1505
1506
 
1507
1508
1509
1510
1511
1512
0
@@ -1504,7 +1504,9 @@
0
      * Returns:
0
      *     A string formatted like "3 days ago" or "3 days from now".
0
      */
0
-    function relative_time($time, $from = null) {
0
+    function relative_time($when, $from = null) {
0
+        $time = (is_numeric($when)) ? $when : strtotime($when) ;
0
+
0
         $difference = time() - $time;
0
 
0
         if ($difference < 0) {

Comments