? arrow-right.png
? jquery.treeTable.css
? jquery.treeTable.js
? token.css
? token.js
? token.pages.inc
Index: token.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v
retrieving revision 1.7.4.18
diff -u -p -r1.7.4.18 token.module
--- token.module	25 Mar 2010 17:49:43 -0000	1.7.4.18
+++ token.module	25 Mar 2010 20:34:17 -0000
@@ -409,6 +409,7 @@ function token_get_date_token_info($desc
   $tokens[$token_prefix . 'dd']     = t("!description day (two digits with leading zeros)", array('!description' => $description));
   $tokens[$token_prefix . 'd']      = t("!description day (one or two digits without leading zeros)", array('!description' => $description));
   $tokens[$token_prefix . 'raw']    = t("!description in UNIX timestamp format (1269441371)", array('!description' => $description));
+  $tokens[$token_prefix . 'since']  = t("!description in 'time-since' format. (40 years 3 months)", array('!description' => $description));
   return $tokens;
 }
 
@@ -419,6 +420,7 @@ function token_get_date_token_info($desc
  */
 function token_get_date_token_values($timestamp, $token_prefix = '') {
   $tokens = array();
+  $time = time();
   $timezone = variable_get('date_default_timezone', 0);
 
   $formats = array(
@@ -440,6 +442,7 @@ function token_get_date_token_values($ti
   }
 
   $tokens[$token_prefix . 'raw'] = $timestamp;
+  $tokens[$token_prefix . 'since'] = format_interval($time - $timestamp);
 
   $timestamp += $timezone;
   if (version_compare(PHP_VERSION, '5.1.0', '>=')) {
Index: token.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.test,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 token.test
--- token.test	25 Mar 2010 20:18:50 -0000	1.1.2.5
+++ token.test	25 Mar 2010 20:34:17 -0000
@@ -40,6 +40,7 @@ class TokenNodeTestCase extends TokenTes
   }
 
   function testNodeTokens() {
+    $time = time();
     $created = gmmktime(0, 0, 0, 11, 19, 1978);
     $changed = gmmktime(0, 0, 0, 7, 4, 1984);
     $node = $this->drupalCreateNode(array(
@@ -67,6 +68,7 @@ class TokenNodeTestCase extends TokenTes
       'dd' => '19',
       'd' => '19',
       'raw' => 280281600,
+      'since' => format_interval($time - 280281600),
       'mod-yyyy' => '1984',
       'mod-yy' => '84',
       'mod-month' => 'July',
@@ -80,6 +82,7 @@ class TokenNodeTestCase extends TokenTes
       'mod-dd' => '04',
       'mod-d' => '4',
       'mod-raw' => 457747200,
+      'mod-since' => format_interval($time - 457747200),
     );
     $this->assertTokens('node', $node, $tokens);
   }
@@ -123,6 +126,7 @@ class TokenCommentTestCase extends Token
   }
 
   function testCommentTokens() {
+    $time = time();
     $comment = $this->createComment(array(
       'timestamp' => gmmktime(0, 0, 0, 7, 4, 1984),
     ));
@@ -143,6 +147,7 @@ class TokenCommentTestCase extends Token
       'comment-dd' => '04',
       'comment-d' => '4',
       'comment-raw' => '457747200',
+      'comment-since' => format_interval($time - 457747200),
     );
     $this->assertTokens('comment', $comment, $tokens);
 
