? local_time_1.patch
? local_time_working.patch
Index: clock.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.js,v
retrieving revision 1.9.2.5
diff -u -p -r1.9.2.5 clock.js
--- clock.js	3 May 2010 16:30:49 -0000	1.9.2.5
+++ clock.js	17 May 2010 22:01:48 -0000
@@ -11,7 +11,9 @@ Drupal.behaviors.clockDisplay = function
 
   // Gets the correct variables from PHP.
   // Whether or not to update the clock continuously
-  var update = Drupal.settings['js'];
+  var update = Drupal.settings['update'];
+  // Whether or not to use the client's local time.
+  var local = Drupal.settings['local'];
   // Creates a JavaScript date object, from a specially formatted date string.
   var date = new Date(Drupal.settings['time']);
   // The time zone offset in seconds.
@@ -19,9 +21,13 @@ Drupal.behaviors.clockDisplay = function
   // The name of the timezone, e.g. 'Europe/London'.
   var timezoneName = Drupal.settings['timezone_name'];
   // If time zone is set to 'Local' overwrite the date.
-  if (timezoneName == 'Local') {
-    var date = new Date();
+  // Note that due to JavaScript's inferior time zone handling, time zone
+  // related date formatters will return the time zone of the Drupal site, not
+  // the visiting user.
+  if (local) {
+    date = new Date();
   }
+
   // Daylight Savings Time information. '1' for yes, '0' for no.
   var daylightSavingsTime = Drupal.settings['daylight_savings_time'];
   // The name of the offset, e.g. 'GMT'.
Index: clock.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.module,v
retrieving revision 1.9.2.9
diff -u -p -r1.9.2.9 clock.module
--- clock.module	3 May 2010 16:06:13 -0000	1.9.2.9
+++ clock.module	17 May 2010 22:01:48 -0000
@@ -225,22 +225,24 @@ function clock_get_timezone() {
   $timezone_type = variable_get('clock_timezone_type', 'site');
 
   switch ($timezone_type) {
-    // Site time zone
+    // Site time zone.
     case '1':
       $timezone = variable_get('date_default_timezone_name', 'UTC');
       break;
-    // User time zone
+    // User time zone.
     case '2':
       $timezone = NULL;
       break;
+    // Local time zone.
     case '3':
       $timezone = 'Local';
-    // Custom time zone
+      break;
+    // Custom time zone..
     case '4':
       $timezone = variable_get('clock_custom_timezone', 'UTC');
       break;
   }
-
+  print_r($timezone);
   return $timezone;
 }
 
@@ -256,12 +258,16 @@ function clock_get_date_format() {
   switch ($date_format_type) {
     case 'short':
       $date_format = variable_get('date_format_short', 'd/m/Y - H:i');
+      break;
     case 'medium':
       $date_format = variable_get('date_format_medium', 'l, m/d/Y, g:i a');
+      break;
     case 'long':
       $date_format = variable_get('date_format_long', 'l, Y,  F j - H:i');
+      break;
     case 'custom':
       $date_format = variable_get('clock_custom_date_format', 'g:i a');
+      break;
   }
 
   return $date_format;
@@ -273,6 +279,12 @@ function clock_get_date_format() {
 function theme_clock($timezone, $date_format, $js) {
   if ($js == '1' || $timezone == 'Local') {
 
+    if ($timezone == 'Local') {
+      $local = TRUE;
+      // Use the site time zone as a fallback for non-JavaScript users.
+      $timezone = variable_get('date_default_timezone_name', 'UTC');
+    }
+
     // Create variables that are needed for the JavaScript time calculation.
     // Create a time string.
     $time = date_format_date(date_now($timezone), $type = 'custom', $format = 'F j, Y H:i:s');
@@ -286,7 +298,8 @@ function theme_clock($timezone, $date_fo
 
     // Pass the variables to JavaScript.
     drupal_add_js(array(
-      'js' => $js,
+      'update' => $js,
+      'local' => $local,
       'time' => $time,
       'offset_seconds' => $offset_seconds,
       'timezone_name' => $timezone,
