Index: token_comment.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/token/Attic/token_comment.inc,v
retrieving revision 1.3.4.5
diff -u -r1.3.4.5 token_comment.inc
--- token_comment.inc	31 May 2009 15:56:09 -0000	1.3.4.5
+++ token_comment.inc	7 Mar 2010 09:58:50 -0000
@@ -52,18 +52,7 @@
       // Included in case a consuming module wants to format the body
       $values['comment-body-format']     = $comment->format;
 
-      $values['comment-yyyy']            = date('Y', $comment->timestamp);
-      $values['comment-yy']              = date('y', $comment->timestamp);
-      $values['comment-month']           = date('F', $comment->timestamp);
-      $values['comment-mon']             = date('M', $comment->timestamp);
-      $values['comment-mm']              = date('m', $comment->timestamp);
-      $values['comment-m']               = date('n', $comment->timestamp);
-      $values['comment-ww']              = date('W', $comment->timestamp);
-      $values['comment-date']            = date('N', $comment->timestamp);
-      $values['comment-day']             = date('l', $comment->timestamp);
-      $values['comment-ddd']             = date('D', $comment->timestamp);
-      $values['comment-dd']              = date('d', $comment->timestamp);
-      $values['comment-d']               = date('j', $comment->timestamp);
+      $values += token_create_date_tokens($comment->timestamp, 'comment-');
       break;
   }
 
@@ -90,19 +79,8 @@
     $tokens['comment']['comment-author-mail']     = t("Comment author's e-mail.");
     $tokens['comment']['comment-author-mail-raw'] = t("Comment author's e-mail. WARNING - raw user input.");
 
-    $tokens['comment']['comment-yyyy']            = t("Comment creation year (four digit)");
-    $tokens['comment']['comment-yy']              = t("Comment creation year (two digit)");
-    $tokens['comment']['comment-month']           = t("Comment creation month (full word)");
-    $tokens['comment']['comment-mon']             = t("Comment creation month (abbreviated)");
-    $tokens['comment']['comment-mm']              = t("Comment creation month (two digit, zero padded)");
-    $tokens['comment']['comment-m']               = t("Comment creation month (one or two digit)");
-    $tokens['comment']['comment-ww']              = t("Comment creation week (two digit)");
-    $tokens['comment']['comment-date']            = t("Comment creation date (day of month)");
-    $tokens['comment']['comment-day']             = t("Comment creation day (full word)");
-    $tokens['comment']['comment-ddd']             = t("Comment creation day (abbreviation)");
-    $tokens['comment']['comment-dd']              = t("Comment creation day (two digit, zero-padded)");
-    $tokens['comment']['comment-d']               = t("Comment creation day (one or two digit)");
+    $tokens['comment'] += token_get_date_token_info(t('Comment'), 'comment-');
 
     return $tokens;
   }
-}
\ No newline at end of file
+}
Index: token_node.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/token/Attic/token_node.inc,v
retrieving revision 1.5.4.18
diff -u -r1.5.4.18 token_node.inc
--- token_node.inc	6 Mar 2010 17:25:30 -0000	1.5.4.18
+++ token_node.inc	7 Mar 2010 09:58:50 -0000
@@ -23,7 +23,7 @@
     case 'node':
       $node = $object;
       $account = db_fetch_object(db_query("SELECT name, mail FROM {users} WHERE uid = %d", $node->uid));
-      
+
       // Adjust for the anonymous user name.
       if (!$node->uid && !$account->name) {
         $account->name = variable_get('anonymous', t('Anonymous'));
@@ -51,35 +51,11 @@
       }
 
       if (isset($node->created)) {
-        $date = (int)$node->created;
-        $values['yyyy']           = date('Y', $date);
-        $values['yy']             = date('y', $date);
-        $values['month']          = date('F', $date);
-        $values['mon']            = date('M', $date);
-        $values['mm']             = date('m', $date);
-        $values['m']              = date('n', $date);
-        $values['ww']             = date('W', $date);
-        $values['date']           = date('N', $date);
-        $values['day']            = date('l', $date);
-        $values['ddd']            = date('D', $date);
-        $values['dd']             = date('d', $date);
-        $values['d']              = date('j', $date);
+        $values += token_get_date_token_values($node->created);
       }
 
       if (isset($node->changed)) {
-        $date = (int)$node->changed;
-        $values['mod-yyyy']       = date('Y', $date);
-        $values['mod-yy']         = date('y', $date);
-        $values['mod-month']      = date('F', $date);
-        $values['mod-mon']        = date('M', $date);
-        $values['mod-mm']         = date('m', $date);
-        $values['mod-m']          = date('n', $date);
-        $values['mod-ww']         = date('W', $date);
-        $values['mod-date']       = date('N', $date);
-        $values['mod-day']        = date('l', $date);
-        $values['mod-ddd']        = date('D', $date);
-        $values['mod-dd']         = date('d', $date);
-        $values['mod-d']          = date('j', $date);
+        $values += token_get_date_token_values($node->changed, 'mod-');
       }
 
       // Try to get the menu data.
@@ -210,18 +186,7 @@
     // Temporarily disabled -- see notes in node_token_values.
     // $tokens['node']['catpath']        = t("Full taxonomy tree for the topmost term");
 
-    $tokens['node']['yyyy']            = t("Node creation year (four digit)");
-    $tokens['node']['yy']              = t("Node creation year (two digit)");
-    $tokens['node']['month']           = t("Node creation month (full word)");
-    $tokens['node']['mon']             = t("Node creation month (abbreviated)");
-    $tokens['node']['mm']              = t("Node creation month (two digit, zero padded)");
-    $tokens['node']['m']               = t("Node creation month (one or two digit)");
-    $tokens['node']['ww']              = t("Node creation week (two digit)");
-    $tokens['node']['date']            = t("Node creation date (day of month)");
-    $tokens['node']['day']             = t("Node creation day (full word)");
-    $tokens['node']['ddd']             = t("Node creation day (abbreviation)");
-    $tokens['node']['dd']              = t("Node creation day (two digit, zero-padded)");
-    $tokens['node']['d']               = t("Node creation day (one or two digit)");
+    $tokens['node'] += token_get_date_token_info(t('Node'), 'node-');
     $tokens['node']['mod-????']        = t('All tokens for node creation dates can also be used with with the "mod-" prefix; doing so will use the modification date rather than the creation date.');
 
     $tokens['node']['menu']                = t("The name of the menu the node belongs to.");
Index: token.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/token/token.module,v
retrieving revision 1.7.4.15
diff -u -r1.7.4.15 token.module
--- token.module	7 Mar 2010 02:22:59 -0000	1.7.4.15
+++ token.module	7 Mar 2010 09:58:50 -0000
@@ -86,23 +86,11 @@
       $values['site-mission'] = filter_xss_admin(variable_get('site_mission', ''));
       $values['site-mail']    = variable_get('site_mail', '');
       $time = time(); $tz = variable_get('date_default_timezone', 0);
-      $values['site-date']       = format_date($time, 'small',   '', $tz);
-      // Date parts, similar to dates in node_token.inc#node_token_values().
-      $values['site-date-yyyy']  = format_date($time, 'custom', 'Y', $tz);
-      $values['site-date-yy']    = format_date($time, 'custom', 'y', $tz);
-      $values['site-date-month'] = format_date($time, 'custom', 'F', $tz);
-      $values['site-date-mon']   = format_date($time, 'custom', 'M', $tz);
-      $values['site-date-mm']    = format_date($time, 'custom', 'm', $tz);
-      $values['site-date-m']     = format_date($time, 'custom', 'n', $tz);
-      $values['site-date-ww']    = format_date($time, 'custom', 'W', $tz);
-      $values['site-date-date']  = format_date($time, 'custom', 'N', $tz);
-      $values['site-date-day']   = format_date($time, 'custom', 'l', $tz);
-      $values['site-date-ddd']   = format_date($time, 'custom', 'D', $tz);
-      $values['site-date-dd']    = format_date($time, 'custom', 'd', $tz);
-      $values['site-date-d']     = format_date($time, 'custom', 'j', $tz);
+      $values['site-date']    = format_date($time, 'small',   '', $tz);
+      $values += token_get_date_token_values($time, 'site-date-');
       // The page number may or may not be present. If it is, it may be comma separated values in which case grab the first.
       $page = isset($_GET['page']) ? $_GET['page'] : '';
-      $values['page-number']     = 1 + (int)(($p = strpos($page, ',')) ? substr($page, 0, $p) : $page);
+      $values['page-number']  = 1 + (int)(($p = strpos($page, ',')) ? substr($page, 0, $p) : $page);
       break;
   }
   return $values;
@@ -132,20 +120,7 @@
   $tokens['global']['site-mission'] = t('The mission of the current Drupal website.');
   $tokens['global']['site-mail']    = t('The contact email address for the current Drupal website.');
   $tokens['global']['site-date']    = t("The current date on the site's server.");
-  // Date parts, similar to dates in node_token.inc#node_token_values().
-  $tokens['global']['site-date-yyyy']  = t('The current year (four digit)');
-  $tokens['global']['site-date-yy']    = t('The current year (two digit)');
-  $tokens['global']['site-date-month'] = t('The current month (full word)');
-  $tokens['global']['site-date-mon']   = t('The current month (abbreviated)');
-  $tokens['global']['site-date-mm']    = t('The current month (two digit, zero padded)');
-  $tokens['global']['site-date-m']     = t('The current month (one or two digit)');
-  $tokens['global']['site-date-ww']    = t('The current week (two digit)');
-  $tokens['global']['site-date-date']  = t('The current date (day of month)');
-  $tokens['global']['site-date-day']   = t('The current day (full word)');
-  $tokens['global']['site-date-ddd']   = t('The current day of week (abbreviation)');
-  $tokens['global']['site-date-dd']    = t('The current day (two digit, zero-padded)');
-  $tokens['global']['site-date-d']     = t('The current day (one or two digit)');
-  $tokens['global']['page-number']     = t('The current page number for paged lists');
+  $tokens['global'] += token_get_date_token_info(t('The current'), 'site-date-');
   return $tokens;
 }
 
@@ -412,3 +387,44 @@
       return crc32(serialize($object));
   }
 }
+
+function token_get_date_token_info($description, $token_prefix = '') {
+  $tokens[$token_prefix . 'yyyy']  = t("!description creation year (four digit)", array('!description' => $description));
+  $tokens[$token_prefix . 'yy']    = t("!description creation year (two digit)", array('!description' => $description));
+  $tokens[$token_prefix . 'month'] = t("!description creation month (full word)", array('!description' => $description));
+  $tokens[$token_prefix . 'mon']   = t("!description creation month (abbreviated)", array('!description' => $description));
+  $tokens[$token_prefix . 'mm']    = t("!description creation month (two digit, zero padded)", array('!description' => $description));
+  $tokens[$token_prefix . 'm']     = t("!description creation month (one or two digit)", array('!description' => $description));
+  $tokens[$token_prefix . 'ww']    = t("!description creation week (two digit)", array('!description' => $description));
+  $tokens[$token_prefix . 'date']  = t("!description creation date (day of month)", array('!description' => $description));
+  $tokens[$token_prefix . 'day']   = t("!description creation day (full word)", array('!description' => $description));
+  $tokens[$token_prefix . 'ddd']   = t("!description creation day (abbreviation)", array('!description' => $description));
+  $tokens[$token_prefix . 'dd']    = t("!description creation day (two digit, zero-padded)", array('!description' => $description));
+  $tokens[$token_prefix . 'd']     = t("!description creation day (one or two digit)", array('!description' => $description));
+  return $tokens;
+}
+
+function token_get_date_token_values($timestamp, $token_prefix = '') {
+  $timezone = variable_get('date_default_timezone', 0);
+  $tokens = array();
+  $formats = array(
+    'yyyy' => 'Y',
+    'yy' => 'y',
+    'month' => 'F',
+    'mon' => 'M',
+    'mm' => 'm',
+    'm' => 'n',
+    'ww' => 'W',
+    'day' => 'l',
+    'ddd' => 'D',
+    'dd' => 'd',
+    'd' => 'j',
+  );
+  foreach ($formats as $token => $format) {
+    $tokens[$token_prefix . $token] = format_date($timestamp, 'custom', $format, $timezone);
+  }
+  $timestamp += $timezone;
+  // format_date() does not support the format N
+  $tokens[$token_prefix . 'date'] = gmdate('N', $timestamp);
+  return $tokens;
+}
