? LICENSE.txt
? clock.make
Index: clock.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.js,v
retrieving revision 1.10
diff -u -p -r1.10 clock.js
--- clock.js	18 Feb 2010 04:58:51 -0000	1.10
+++ clock.js	21 Mar 2010 20:51:03 -0000
@@ -9,18 +9,20 @@
 Drupal.behaviors.clockDisplay = {
   attach: function (context, settings) {
 
+    // Whether or not to update the clock continuously
+    var clockUpdate = Drupal.settings['0'];
     // Gets a PHP timestamp, which counts the seconds since the begin of the UNIX-era.
-    var clockTimestampString = settings['0'];
+    var clockTimestampString = settings['1'];
     // The time zone offset in seconds.
-    var clockTimezoneOffsetSeconds = settings['1'];
+    var clockTimezoneOffsetSeconds = settings['2'];
     // The name of the timezone, e.g. 'Europe/London'.
-    var clockTimezoneName = settings['2'];
+    var clockTimezoneName = settings['3'];
     // Daylight Savings Time information. '1' for yes, '0' for no.
-    var clockDaylightSavingsTime = settings['3'];
+    var clockDaylightSavingsTime = settings['4'];
     // The name of the offset, e.g. 'GMT'.
-    var clockOffsetName = settings['4'];
+    var clockOffsetName = settings['5'];
     // A PHP date format string.
-    var clockDateFormat = settings['5'];
+    var clockDateFormat = settings['6'];
 
     // Calculate the timestamp with the time zone offset and turn it into milliseconds.
     // JavaScript's time handling is based on milliseconds, while PHP's is based on seconds.
@@ -377,18 +379,36 @@ Drupal.behaviors.clockDisplay = {
         }
       }
       return formattedDate;
-    }
-
+    }
+
+    if (clockUpdate == '1') {
+
+      // Format the clock.
+      if (clockTimezoneName == 'Local') {
+        var clockDate = new Date();
+      }
+      else {
+        var clockDate = new Date(clockTimestamp);
+      }
+      clock = formatDate(clockDate, clockTimestamp, clockDateFormat, clockTimezoneOffsetSeconds, clockTimezoneName, clockDaylightSavingsTime, clockOffsetName);
+      $('div.clock').html(clock);
+
+      // Recalculate the date every second. '.everyTime' is provided by jQuery Timers.
+      $(document).everyTime(1000, function() {
+        // Add 1 second to the timestamp.
+        clockTimestamp = clockTimestamp + 1000;
+        // Format the timestamp into the given format.
+        if (clockTimezoneName == 'Local') {
+          clockDate = new Date();
+        }
+        else {
+          clockDate = new Date(clockTimestamp);
+        }
+        clock = formatDate(clockDate, clockTimestamp, clockDateFormat, clockTimezoneOffsetSeconds, clockTimezoneName, clockDaylightSavingsTime, clockOffsetName);
+        $('div.clock').html(clock);
+      }, 0);
 
-    // Recalculate the date every second. '.everyTime' is provided by jQuery Timers.
-    $(document).everyTime(1000, function() {
-      // Add 1 second to the timestamp.
-      clockTimestamp = clockTimestamp + 1000;
-      // Format the timestamp into the given format.
-      clockDate = new Date(clockTimestamp);
-      clock = formatDate(clockDate, clockTimestamp, clockDateFormat, clockTimezoneOffsetSeconds, clockTimezoneName, clockDaylightSavingsTime, clockOffsetName);
-      $('div.clock').html(clock);
-    }, 0);
+    }
 
   }
 }
Index: clock.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.module,v
retrieving revision 1.10
diff -u -p -r1.10 clock.module
--- clock.module	18 Feb 2010 04:58:51 -0000	1.10
+++ clock.module	21 Mar 2010 20:51:04 -0000
@@ -28,14 +28,16 @@ function clock_block_configure($delta = 
     if (variable_get('configurable_timezones', 1) == 1) {
       $form['timezone']['#options'] = array(
         '1' => t('Site time zone'),
-        '2' => t('User time zone'),
-        '3' => t('Custom time zone'),
+        '2' => t('User time zone'),
+        '3' => t('Local time zone'),
+        '4' => t('Custom time zone'),
       );
     }
     else {
       $form['timezone']['#options'] = array(
         '1' => t('Site time zone'),
-        '3' => t('Custom time zone'),
+        '3' => t('Local time zone'),
+        '4' => t('Custom time zone'),
       );
     }
     $form['custom_timezone'] = array(
@@ -48,7 +50,7 @@ function clock_block_configure($delta = 
       // This does not seem to be working currently.
       '#states' => array(
         'invisible' => array(
-          'input[id="edit-timezone-3"]' => array('checked' => FALSE),
+          'input[id="edit-timezone-4"]' => array('checked' => FALSE),
         ),
       ),
     );
@@ -84,7 +86,7 @@ function clock_block_configure($delta = 
 function clock_block_save($delta = '', $edit = array()) {
   if ($delta == 'clock') {
     variable_set('clock_timezone_type', $edit['timezone']);
-    if ($edit['timezone'] == '3') {
+    if ($edit['timezone'] == '4') {
       variable_set('clock_custom_timezone', $edit['custom_timezone']);
     }
     variable_set('clock_date_format_type', $edit['date_format']);
@@ -100,7 +102,7 @@ function clock_block_view($delta = '') {
   if ($delta == 'clock') {
     $block = array();
     $block['subject'] = 'Clock';
-    $block['content'] = theme_clock(_clock_get_timezone(), _clock_get_date_format(), variable_get('clock_js', '1'));
+    $block['content'] = theme_clock(variable_get('clock_timezone_type', '1'), _clock_get_timezone(), _clock_get_date_format(), variable_get('clock_js', '1'));
     return $block;
   }
 }
@@ -108,13 +110,15 @@ function clock_block_view($delta = '') {
 /*
  * Get the correct timezone to display.
  *
- * @return The name of the timezone or NULL if the user's time zone is to be used.
+ * @return The name of the timezone, NULL if the user's time zone is to be used or 'Local' is the user's local time is to be used.
  */
 function _clock_get_timezone() {
-  $clock_timezone_type = variable_get('clock_timezone_type', 'site');
+  $clock_timezone_type = variable_get('clock_timezone_type', '1');
   switch ($clock_timezone_type) {
     // Site time zone
-    case '1':
+    case '1':
+    // If time zone is set to 'Local' and the user has JS disabled, show the site time zone.
+    case '3':
       $clock_timezone = variable_get('date_default_timezone_name', 'UTC');
       break;
     // User time zone
@@ -122,7 +126,7 @@ function _clock_get_timezone() {
       $clock_timezone = NULL;
       break;
     // Custom time zone
-    case '3':
+    case '4':
       $clock_timezone = variable_get('clock_custom_timezone', 'UTC');
       break;
   }
@@ -152,7 +156,8 @@ function _clock_get_date_format($type = 
 function clock_theme() {
   return array(
     'clock' => array(
-      'variables' => array(
+      'variables' => array(
+        'clock_timezone_type' => '1',
         'clock_timezone' => 'UTC',
         'clock_date_format' => 'short',
         'clock_js' => '1',
@@ -164,18 +169,23 @@ function clock_theme() {
 /*
  * Provide a default implementation of theme_clock().
  */
-function theme_clock($clock_timezone = 'UTC', $clock_date_format = 'g:i a', $clock_js = '1') {
+function theme_clock($clock_timezone_type = '1', $clock_timezone = 'UTC', $clock_date_format = 'g:i a', $clock_js = '1') {
   $output = '';
 
-  if ($clock_js == '1') {
+  if ($clock_js == '1' || $clock_timezone_type == '3') {
     // Create a timestamp.
     $clock_timestamp = date_format_date(date_now($timezone = $clock_timezone), $type = 'custom', $format = 'U');
 
     // Get the time zone offset in seconds.
     $clock_timezone_offset_seconds = date_format_date(date_now($timezone = $clock_timezone), $type = 'custom', $format = 'Z');
 
-    // Get the name of the time zone, e.g. 'Europe/London'.
-    $clock_timezone_name = date_format_date(date_now($timezone = $clock_timezone), $type = 'custom', $format = 'e');
+    // Get the name of the time zone, e.g. 'Europe/London'. 'Local' if the user's local time is to be displayed.
+    if ($clock_timezone_type == '3') {
+      $clock_timezone_name = 'Local';
+    }
+    else {
+      $clock_timezone_name = date_format_date(date_make_date($date = 'now', $timezone = $clock_timezone), $type = 'custom', $format = 'e');
+    }
 
     // Get Daylight Savings Time information. '1' for yes, '0' for no.
     $clock_daylight_savings_time = date_format_date(date_now($timezone = $clock_timezone), $type = 'custom', $format = 'I');
@@ -184,13 +194,14 @@ function theme_clock($clock_timezone = '
     $clock_offset_name = date_format_date(date_now($timezone = $clock_timezone), $type = 'custom', $format = 'T');
 
     // Pass the variables to JavaScript.
-    drupal_add_js(array(
-      '0' => $clock_timestamp,
-      '1' => $clock_timezone_offset_seconds,
-      '2' => $clock_timezone_name,
-      '3' => $clock_daylight_savings_time,
-      '4' => $clock_offset_name,
-      '5' => $clock_date_format,
+    drupal_add_js(array(
+      '0' => $clock_js,
+      '1' => $clock_timestamp,
+      '2' => $clock_timezone_offset_seconds,
+      '3' => $clock_timezone_name,
+      '4' => $clock_daylight_savings_time,
+      '5' => $clock_offset_name,
+      '6' => $clock_date_format,
     ), 'setting');
 
     drupal_add_js(drupal_get_path('module', 'clock') . '/jquery.timers.js');
