? jquery.timers.js
Index: clock.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.js,v
retrieving revision 1.12
diff -u -p -r1.12 clock.js
--- clock.js	3 May 2010 17:56:53 -0000	1.12
+++ clock.js	4 May 2010 16:56:10 -0000
@@ -11,118 +11,121 @@
 Drupal.behaviors.clockDisplay = {
   attach: function (context, settings) {
 
-  // Gets the correct variables from PHP.
-  // Creates a JavaScript date object, from a specially formatted date string.
-  var date = new Date(Drupal.settings['time']);
-  // A PHP date format string.
-  var dateFormat = Drupal.settings['date_format'];
-  // 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();
-  }
-  // The name of the offset, e.g. 'GMT'.
-  var offsetName = Drupal.settings['offset_name'];
-  // The time zone offset in seconds.
-  var offsetSeconds = Drupal.settings['offset_seconds'];
-  // Daylight Savings Time information. '1' for yes, '0' for no.
-  var daylightSavingsTime = Drupal.settings['daylight_savings_time'];
-  // Whether or not to update the clock continuously
-  var update = Drupal.settings['js'];
-
-  // Create an array containing month names.
-  var monthNames = new Array();
-  monthNames[1] = new Object();
-  monthNames[1]['long'] = Drupal.t('January');
-  monthNames[1]['short'] = Drupal.t('Jan');
-  monthNames[2] = new Object();
-  monthNames[2]['long'] = Drupal.t('February');
-  monthNames[2]['short'] = Drupal.t('Feb');
-  monthNames[3] = new Object();
-  monthNames[3]['long'] = Drupal.t('March');
-  monthNames[3]['short'] = Drupal.t('Mar');
-  monthNames[4] = new Object();
-  monthNames[4]['long'] = Drupal.t('April');
-  monthNames[4]['short'] = Drupal.t('Apr');
-  monthNames[5] = new Object();
-  monthNames[5]['long'] = Drupal.t('May');
-  // Use context if http://drupal.org/node/488496 gets in.
-  monthNames[5]['short'] = Drupal.t('May');
-  monthNames[6] = new Object();
-  monthNames[6]['long'] = Drupal.t('June');
-  monthNames[6]['short'] = Drupal.t('Jun');
-  monthNames[7] = new Object();
-  monthNames[7]['long'] = Drupal.t('July');
-  monthNames[7]['short'] = Drupal.t('Jul');
-  monthNames[8] = new Object();
-  monthNames[8]['long'] = Drupal.t('August');
-  monthNames[8]['short'] = Drupal.t('Aug');
-  monthNames[9] = new Object();
-  monthNames[9]['long'] = Drupal.t('September');
-  monthNames[9]['short'] = Drupal.t('Sep');
-  monthNames[10] = new Object();
-  monthNames[10]['long'] = Drupal.t('October');
-  monthNames[10]['short'] = Drupal.t('Oct');
-  monthNames[11] = new Object();
-  monthNames[11]['long'] = Drupal.t('November');
-  monthNames[11]['short'] = Drupal.t('Nov');
-  monthNames[12] = new Object();
-  monthNames[12]['long'] = Drupal.t('December');
-  monthNames[12]['short'] = Drupal.t('Dec');
-
-  // Create an array containing weekday names.
-  var weekdayNames = new Array();
-  weekdayNames[0] = new Object();
-  weekdayNames[0]['long'] = Drupal.t('Sunday');
-  weekdayNames[0]['short'] = Drupal.t('Sun');
-  weekdayNames[1] = new Object();
-  weekdayNames[1]['long'] = Drupal.t('Monday');
-  weekdayNames[1]['short'] = Drupal.t('Mon');
-  weekdayNames[2] = new Object();
-  weekdayNames[2]['long'] = Drupal.t('Tuesday');
-  weekdayNames[2]['short'] = Drupal.t('Tue');
-  weekdayNames[3] = new Object();
-  weekdayNames[3]['long'] = Drupal.t('Wednesday');
-  weekdayNames[3]['short'] = Drupal.t('Wed');
-  weekdayNames[4] = new Object();
-  weekdayNames[4]['long'] = Drupal.t('Thursday');
-  weekdayNames[4]['short'] = Drupal.t('Thu');
-  weekdayNames[5] = new Object();
-  weekdayNames[5]['long'] = Drupal.t('Friday');
-  weekdayNames[5]['short'] = Drupal.t('Fri');
-  weekdayNames[6] = new Object();
-  weekdayNames[6]['long'] = Drupal.t('Saturday');
-  weekdayNames[6]['short'] = Drupal.t('Sat');
-
-  // Prepare the timezone array.
-  var timezone = new Array();
-  timezone['name'] = timezoneName;
-  timezone['offsetSeconds'] = offsetSeconds;
-  timezone['daylightSavingsTime'] = daylightSavingsTime;
-  timezone['offsetName'] = offsetName;
-
-  // Format the clock.
-  clock = formatDate(date, dateFormat, timezone, monthNames, weekdayNames);
-  $('div.clock').html(clock);
-
-  if (update == '1') {
-
-    // Recalculate the date every second. '.everyTime' is provided by jQuery Timers.
-    $(document).everyTime(1000, function() {
-
-      // Add 1 second to the time.
-      var clockTimestamp = date.getTime();
-      clockTimestamp = clockTimestamp + 1000;
-      date = new Date(clockTimestamp);
-
-      // Format the clock.
-      clock = formatDate(date, dateFormat, timezone, monthNames, weekdayNames);
-      $('div.clock').html(clock);
-    }, 0);
+    // Gets the correct variables from PHP.
+    // Creates a JavaScript date object, from a specially formatted date string.
+    var date = new Date(Drupal.settings['time']);
+    // A PHP date format string.
+    var dateFormat = Drupal.settings['date_format'];
+    // 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();
+    }
+    // The name of the offset, e.g. 'GMT'.
+    var offsetName = Drupal.settings['offset_name'];
+    // The time zone offset in seconds.
+    var offsetSeconds = Drupal.settings['offset_seconds'];
+    // Daylight Savings Time information. '1' for yes, '0' for no.
+    var daylightSavingsTime = Drupal.settings['daylight_savings_time'];
+    // Whether or not to update the clock continuously
+    var update = Drupal.settings['js'];
+
+    // Create an array containing month names.
+    var monthNames = new Array();
+    monthNames[1] = new Object();
+    monthNames[1]['long'] = Drupal.t('January');
+    monthNames[1]['short'] = Drupal.t('Jan');
+    monthNames[2] = new Object();
+    monthNames[2]['long'] = Drupal.t('February');
+    monthNames[2]['short'] = Drupal.t('Feb');
+    monthNames[3] = new Object();
+    monthNames[3]['long'] = Drupal.t('March');
+    monthNames[3]['short'] = Drupal.t('Mar');
+    monthNames[4] = new Object();
+    monthNames[4]['long'] = Drupal.t('April');
+    monthNames[4]['short'] = Drupal.t('Apr');
+    monthNames[5] = new Object();
+    monthNames[5]['long'] = Drupal.t('May');
+    // Use context if http://drupal.org/node/488496 gets in.
+    monthNames[5]['short'] = Drupal.t('May');
+    monthNames[6] = new Object();
+    monthNames[6]['long'] = Drupal.t('June');
+    monthNames[6]['short'] = Drupal.t('Jun');
+    monthNames[7] = new Object();
+    monthNames[7]['long'] = Drupal.t('July');
+    monthNames[7]['short'] = Drupal.t('Jul');
+    monthNames[8] = new Object();
+    monthNames[8]['long'] = Drupal.t('August');
+    monthNames[8]['short'] = Drupal.t('Aug');
+    monthNames[9] = new Object();
+    monthNames[9]['long'] = Drupal.t('September');
+    monthNames[9]['short'] = Drupal.t('Sep');
+    monthNames[10] = new Object();
+    monthNames[10]['long'] = Drupal.t('October');
+    monthNames[10]['short'] = Drupal.t('Oct');
+    monthNames[11] = new Object();
+    monthNames[11]['long'] = Drupal.t('November');
+    monthNames[11]['short'] = Drupal.t('Nov');
+    monthNames[12] = new Object();
+    monthNames[12]['long'] = Drupal.t('December');
+    monthNames[12]['short'] = Drupal.t('Dec');
+
+    // Create an array containing weekday names.
+    var weekdayNames = new Array();
+    weekdayNames[0] = new Object();
+    weekdayNames[0]['long'] = Drupal.t('Sunday');
+    weekdayNames[0]['short'] = Drupal.t('Sun');
+    weekdayNames[1] = new Object();
+    weekdayNames[1]['long'] = Drupal.t('Monday');
+    weekdayNames[1]['short'] = Drupal.t('Mon');
+    weekdayNames[2] = new Object();
+    weekdayNames[2]['long'] = Drupal.t('Tuesday');
+    weekdayNames[2]['short'] = Drupal.t('Tue');
+    weekdayNames[3] = new Object();
+    weekdayNames[3]['long'] = Drupal.t('Wednesday');
+    weekdayNames[3]['short'] = Drupal.t('Wed');
+    weekdayNames[4] = new Object();
+    weekdayNames[4]['long'] = Drupal.t('Thursday');
+    weekdayNames[4]['short'] = Drupal.t('Thu');
+    weekdayNames[5] = new Object();
+    weekdayNames[5]['long'] = Drupal.t('Friday');
+    weekdayNames[5]['short'] = Drupal.t('Fri');
+    weekdayNames[6] = new Object();
+    weekdayNames[6]['long'] = Drupal.t('Saturday');
+    weekdayNames[6]['short'] = Drupal.t('Sat');
+
+    // Prepare the timezone array.
+    var timezone = new Array();
+    timezone['name'] = timezoneName;
+    timezone['offsetSeconds'] = offsetSeconds;
+    timezone['daylightSavingsTime'] = daylightSavingsTime;
+    timezone['offsetName'] = offsetName;
+
+    // Format the clock.
+    clock = formatDate(date, dateFormat, timezone, monthNames, weekdayNames);
+    $('div.clock').html(clock);
+
+    if (update == '1') {
+
+      // Recalculate the date every second. '.everyTime' is provided by jQuery Timers.
+      $(document).everyTime(1000, function() {
+
+        // Add 1 second to the time.
+        var clockTimestamp = date.getTime();
+        clockTimestamp = clockTimestamp + 1000;
+        date = new Date(clockTimestamp);
+
+        // Format the clock.
+        clock = formatDate(date, dateFormat, timezone, monthNames, weekdayNames);
+        $('div.clock').html(clock);
+      }, 0);
+
+    }
 
   }
-}
+
+};
 
 })(jQuery);
 
Index: clock.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.module,v
retrieving revision 1.13
diff -u -p -r1.13 clock.module
--- clock.module	3 May 2010 17:56:53 -0000	1.13
+++ clock.module	4 May 2010 16:56:11 -0000
@@ -104,7 +104,7 @@ function clock_block_configure($delta = 
     // Format the current time with each date type to display them in the form.
     $date_types = array();
     foreach(system_get_date_types() as $date_type => $info) {
-      $date_types[$date_type] = $info['title'] . ' (' . date_format_date(date_now(_clock_get_timezone()), 'custom', clock_get_date_format($date_type)) . ')';
+      $date_types[$date_type] = $info['title'] . ' (' . date_format_date(date_now(clock_get_timezone()), 'custom', clock_get_date_format($date_type)) . ')';
     }
     $form['date_format'] = array(
       '#type' => 'radios',
@@ -199,7 +199,8 @@ function clock_get_date_format($type = F
   $date_format = variable_get('date_format_' . $type, '');
   // If the date format has not been specifically set, load the default.
   if (!$date_format) {
-    $date_format = array_shift(array_keys(system_get_date_formats($type)));
+    $date_formats = array_keys(system_get_date_formats($type));
+    $date_format = array_shift($date_formats);
   }
   return $date_format;
 }
