includes/functions.php
changeset 406 7468a663315f
parent 391 85f91037cd4f
child 411 d1a95497b68f
--- a/includes/functions.php	Fri Feb 08 12:16:43 2008 -0500
+++ b/includes/functions.php	Fri Feb 08 23:20:20 2008 -0500
@@ -251,8 +251,29 @@
 {
   if ( !is_int($timestamp) && !is_double($timestamp) && strval(intval($timestamp)) !== $timestamp )
     $timestamp = time();
-  // FIXME: Offset $timestamp by user's timezone
-  return gmdate($string, $timestamp);
+  
+  /*
+  // List of valid characters for date()
+  $date_chars = 'dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZFcrU';
+  // Split them into an array
+  $date_chars = enano_str_split($date_chars);
+  // Emulate date() formatting by replacing date characters with their
+  // percentage-signed counterparts, but not escaped characters which
+  // shouldn't be parsed.
+  foreach ( $date_chars as $char )
+  {
+    $string = str_replace($char, "%$char", $string);
+    $string = str_replace("\\%$char", $char, $string);
+  }
+  */
+  
+  // perform timestamp offset
+  global $timezone;
+  // it's gonna be in minutes, so multiply by 60 to offset the unix timestamp
+  $timestamp = $timestamp + ( $timezone * 60 );
+  
+  // Let PHP do the work for us =)
+  return date($string, $timestamp);
 }
 
 /**