Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/CHANGELOG.txt,v
retrieving revision 1.6.2.1
diff -u -p -r1.6.2.1 CHANGELOG.txt
--- CHANGELOG.txt	20 Apr 2010 21:42:13 -0000	1.6.2.1
+++ CHANGELOG.txt	21 Apr 2010 19:28:07 -0000
@@ -1,4 +1,4 @@
-// $Id: CHANGELOG.txt,v 1.6.2.1 2010/04/20 21:42:13 tstoeckler Exp $
+; $Id: CHANGELOG.txt,v 1.6.2.1 2010/04/20 21:42:13 tstoeckler Exp $
 
 Clock 6.x-1.x-dev
 ----------------------
@@ -25,4 +25,5 @@ Clock 6.x-1.1, 2010-01-28
 
 Clock 6.x-1.0, 2010-01-07
 ----------------------
-- Initial commit. Features the ability to select different timezones and date formats.
+- Initial commit. Features the ability to select different timezones and date
+  formats.
Index: clock.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.info,v
retrieving revision 1.4.2.1
diff -u -p -r1.4.2.1 clock.info
--- clock.info	11 Apr 2010 09:31:53 -0000	1.4.2.1
+++ clock.info	21 Apr 2010 19:28:07 -0000
@@ -6,9 +6,3 @@ package = Date/Time
 dependencies[] = date_api
 dependencies[] = date_timezone
 
-; Information added by drupal.org packaging script on 2010-01-07
-version = "6.x-1.0"
-core = "6.x"
-project = "clock"
-datestamp = "1262841004"
-
Index: clock.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.install,v
retrieving revision 1.4.2.1
diff -u -p -r1.4.2.1 clock.install
--- clock.install	11 Apr 2010 09:31:53 -0000	1.4.2.1
+++ clock.install	21 Apr 2010 19:28:07 -0000
@@ -6,8 +6,8 @@
  * Install, update and uninstall functions for the clock module.
  */
 
-/*
- * Implement hook_uninstall().
+/**
+ * Implements hook_uninstall().
  */
 function clock_uninstall() {
   // Delete all clock variables if they are set.
Index: clock.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.js,v
retrieving revision 1.9.2.3
diff -u -p -r1.9.2.3 clock.js
--- clock.js	10 Apr 2010 16:40:14 -0000	1.9.2.3
+++ clock.js	21 Apr 2010 19:28:08 -0000
@@ -1,31 +1,207 @@
 // $Id: clock.js,v 1.9.2.3 2010/04/10 16:40:14 tstoeckler Exp $
 
-/*
+/**
  * Gets the date format and time zone related parameters from PHP and formats the date according
  * to the php date formatters. Visit http://php.net/date for more information. Using jQuery Timers (http://plugins.jquery.com/project/timers) the
  * date is recalculated every second to make the clock dynamic.
  */
 Drupal.behaviors.clockDisplay = function (context) {
+
+  // Gets the correct variables from PHP.
   // 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 clockTime = Drupal.settings['1'];
+  var update = Drupal.settings['js'];
+  // Creates a JavaScript date object, from a specially formatted date string.
+  var date = new Date(Drupal.settings['time']);
   // The time zone offset in seconds.
-  var clockTimezoneOffsetSeconds = Drupal.settings['2'];
+  var offsetSeconds = Drupal.settings['offset_seconds'];
   // The name of the timezone, e.g. 'Europe/London'.
-  var clockTimezoneName = Drupal.settings['3'];
+  var timezoneName = Drupal.settings['timezone_name'];
   // Daylight Savings Time information. '1' for yes, '0' for no.
-  var clockDaylightSavingsTime = Drupal.settings['4'];
+  var daylightSavingsTime = Drupal.settings['daylight_savings_time'];
   // The name of the offset, e.g. 'GMT'.
-  var clockOffsetName = Drupal.settings['5'];
+  var offsetName = Drupal.settings['offset_name'];
   // A PHP date format string.
-  var clockDateFormat = Drupal.settings['6'];
+  var dateFormat = Drupal.settings['date_format'];
+
+  // Create an array containing month names.
+  var monthNames = new Array();
+  monthNames[1] = new Object();
+  monthNames[1]['longName'] = Drupal.t('January');
+  monthNames[1]['shortName'] = Drupal.t('Jan');
+  monthNames[2] = new Object();
+  monthNames[2]['longName'] = Drupal.t('February');
+  monthNames[2]['shortName'] = Drupal.t('Feb');
+  monthNames[3] = new Object();
+  monthNames[3]['longName'] = Drupal.t('March');
+  monthNames[3]['shortName'] = Drupal.t('Mar');
+  monthNames[4] = new Object();
+  monthNames[4]['longName'] = Drupal.t('April');
+  monthNames[4]['shortName'] = Drupal.t('Apr');
+  monthNames[5] = new Object();
+  monthNames[5]['longName'] = Drupal.t('May');
+  monthNames[5]['shortName'] = Drupal.t('May');
+  monthNames[6] = new Object();
+  monthNames[6]['longName'] = Drupal.t('June');
+  monthNames[6]['shortName'] = Drupal.t('Jun');
+  monthNames[7] = new Object();
+  monthNames[7]['longName'] = Drupal.t('July');
+  monthNames[7]['shortName'] = Drupal.t('Jul');
+  monthNames[8] = new Object();
+  monthNames[8]['longName'] = Drupal.t('August');
+  monthNames[8]['shortName'] = Drupal.t('Aug');
+  monthNames[9] = new Object();
+  monthNames[9]['longName'] = Drupal.t('September');
+  monthNames[9]['shortName'] = Drupal.t('Sep');
+  monthNames[10] = new Object();
+  monthNames[10]['longName'] = Drupal.t('October');
+  monthNames[10]['shortName'] = Drupal.t('Oct');
+  monthNames[11] = new Object();
+  monthNames[11]['longName'] = Drupal.t('November');
+  monthNames[11]['shortName'] = Drupal.t('Nov');
+  monthNames[12] = new Object();
+  monthNames[12]['longName'] = Drupal.t('December');
+  monthNames[12]['shortName'] = 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;
+
+
+  // Initialize the clock variable for later use.
+  var clock = '';
+
+  // If time zone is set to 'Local' overwrite the date.
+  if (timezoneName == 'Local') {
+    var date = new Date();
+  }
 
-  var clockDate = new Date(clockTime);
+  // Format the clock.
+  clock = formatDate(date, dateFormat, timezone);
+  $('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 = getTime(date);
+      clockTimestamp = clockTimestamp + 1000;
+      date = new Date(clockTimestamp);
+
+      // Format the clock.
+      clock = formatDate(date, dateFormat, timezone);
+      $('div.clock').html(clock);
+    }, 0);
 
-  // Calculate whether it is a leap year or not. Years that are multiples of 4 are leap years,
-  // while multiples of 100 are not, but multiples of 400 are. That way 1600, 2000, 2004, 2008 were leap years, while 1700, 1800, 1900 were not.
-  var year = clockDate.getFullYear();
+  }
+}
+
+/*
+ * Hide the select boxes on the clock block configure screen if the specific options are disabled.
+ */
+Drupal.behaviors.clockConfigure = function (context) {
+  // Show the custom time zone select list only when 'Custom time zone' is checked.
+  $('div.edit-custom-timezone').addClass('js-hide');
+  function customTimezoneSelect() {
+    var value = $('div.edit-timezone input:checked').val();
+    if (value == '4') {
+      $('div.edit-custom-timezone').show();
+    }
+    else {
+      $('div.edit-custom-timezone').hide();
+    }
+  }
+  $('div.edit-timezone').bind('click', customTimezoneSelect);
+  customTimezoneSelect();
+
+  // Show the custom date format select list only when 'Custom date format' is checked.
+  $('div.edit-custom-date-format').addClass('js-hide');
+  function customDateFormatSelect() {
+    var value = $('div.edit-date-format input:checked').val();
+    if (value == 'custom') {
+      $('div.edit-custom-date-format').show();
+    }
+    else {
+      $('div.edit-custom-date-format').hide();
+    }
+  }
+  $('div.edit-date-format').bind('click', customDateFormatSelect);
+  customDateFormatSelect();
+}
+
+/**
+ * Format a date into a PHP date string.
+ *
+ * @param date
+ *   A date object.
+ * @param dateFormat
+ *   A string. See http://php.net/date for possible values.
+ * @param timezone
+ *   An associative array containing timezone information. It should consist of
+ *   following keys:
+ *   - timezoneName: The name of the timezone, e.g. 'Europe/London'.
+ *   - offsetSeconds: The timezone offset in seconds.
+ *   - offsetName: The name of the offset, e.g. 'UTC'.
+ *   - daylightSavingsTime: Whether or not the time is in daylight savings time.
+ *     '1' if yes, '0' if not.
+ * @param monthNames
+ *   An array of month names keyed by the numbers 1-12. Each value should in turn
+ *   be an array keyed 'long' and 'short' for the long respective the short
+ *   month names.
+ * @param weekdayNames
+ *   An array of weekday names keyed by the numbers 0 (for Sunday) - 6 (for
+ *   Saturday). Each value should in turn be an array keyed by 'long' and
+ *   'short' for the long respective the short weekday names.
+ *
+ * @return
+ *   A formatted date string.
+ */
+function formatDate(date, dateFormat, timezone, monthNames, weekdayNames) {
+  var timezoneName = timezone['name'];
+  var offsetSeconds = timezone['offsetSeconds'];
+  var offsetName = timezone['offsetName'];
+  var daylightSavingsTime = timezone['daylightSavingsTime'];
+
+
+  // Initialize the 'formattedDate' variable for later use.
+  var formattedDate = '';
+
+  // Prepare variables for the format conversion.
+
+  // Year-related.
+  var year = date.getFullYear();
+  var yearShort = year % 100;
+  // Calculate whether it is a leap year or not. Years that are multiples of 4
+  // are leap years, while multiples of 100 are not, but multiples of 400 are.
+  var year = date.getFullYear();
   if (((year % 4) == 0) && ((year % 100) != 0) || ((year % 400) == 0)) {
     var leapYear = '1';
   }
@@ -33,407 +209,314 @@ Drupal.behaviors.clockDisplay = function
     var leapYear = '0';
   }
 
+  // Month-related.
+  var month = date.getMonth();
+  // JavaScript starts counting the months with 0 instead of 1.
+  month++;
+  var monthLeadingZero = ((month < 10) ? '0' + month : month);
+  var monthLongName = months[month]['longName'];
+  var monthShortName = months[month]['shortName'];
+  var day = date.getDate();
+  var dayLeadingZero = ((day < 10) ? '0' + day : day);
+  switch (day) {
+    case 1:
+      var dayOfMonthAppend = Drupal.t('st');
+      break;
+    case 2:
+      var dayOfMonthAppend = Drupal.t('nd');
+      break;
+    case 3:
+      var dayOfMonthAppend = Drupal.t('rd');
+      break;
+    default:
+      var dayOfMonthAppend = Drupal.t('th');
+      break;
+  }
+  // To calculate the days of the year, iterate through all passed months and then add the current days of the month.
+  var daysOfYear = 0;
+  for (var m = 1; m < month; m++) {
+    daysOfYear += months[m]['days'];
+  }
+  daysOfYear += day;
   // Create an array containing month names and lengths.
   var months = new Array();
   months[1] = new Object();
-  months[1]['longName'] = Drupal.t('January');
-  months[1]['shortName'] = Drupal.t('Jan');
+  months[1]['longName'] = monthNames[1]['long'];
+  months[1]['shortName'] = monthNames[1]['short'];
   months[1]['days'] = 31;
   months[2] = new Object();
-  months[2]['longName'] = Drupal.t('February');
-  months[2]['shortName'] = Drupal.t('Feb');
+  months[2]['longName'] = monthNames[2]['long'];
+  months[2]['shortName'] = monthNames[2]['short'];
   months[2]['days'] = ((leapYear == 1) ? 29 : 28);
   months[3] = new Object();
-  months[3]['longName'] = Drupal.t('March');
-  months[3]['shortName'] = Drupal.t('Mar');
+  months[3]['longName'] = monthNames[3]['long'];
+  months[3]['shortName'] = monthNames[3]['short'];
   months[3]['days'] = 31;
   months[4] = new Object();
-  months[4]['longName'] = Drupal.t('April');
-  months[4]['shortName'] = Drupal.t('Apr');
+  months[4]['longName'] = monthNames[4]['long'];
+  months[4]['shortName'] = monthNames[4]['short'];
   months[4]['days'] = 30;
   months[5] = new Object();
-  months[5]['longName'] = Drupal.t('May');
-  months[5]['shortName'] = Drupal.t('May');
+  months[5]['longName'] = monthNames[5]['long'];
+  months[5]['shortName'] = monthNames[5]['short'];
   months[5]['days'] = 31;
   months[6] = new Object();
-  months[6]['longName'] = Drupal.t('June');
-  months[6]['shortName'] = Drupal.t('Jun');
+  months[6]['longName'] = monthNames[6]['long'];
+  months[6]['shortName'] = monthNames[6]['short'];
   months[6]['days'] = 30;
   months[7] = new Object();
-  months[7]['longName'] = Drupal.t('July');
-  months[7]['shortName'] = Drupal.t('Jul');
+  months[7]['longName'] = monthNames[7]['long'];
+  months[7]['shortName'] = monthNames[7]['short'];
   months[7]['days'] = 31;
   months[8] = new Object();
-  months[8]['longName'] = Drupal.t('August');
-  months[8]['shortName'] = Drupal.t('Aug');
+  months[8]['longName'] = monthNames[8]['long'];
+  months[8]['shortName'] = monthNames[8]['short'];
   months[8]['days'] = 31;
   months[9] = new Object();
-  months[9]['longName'] = Drupal.t('September');
-  months[9]['shortName'] = Drupal.t('Sep');
+  months[9]['longName'] = monthNames[9]['long'];
+  months[9]['shortName'] = monthNames[9]['short'];
   months[9]['days'] = 30;
   months[10] = new Object();
-  months[10]['longName'] = Drupal.t('October');
-  months[10]['shortName'] = Drupal.t('Oct');
+  months[10]['longName'] = monthNames[10]['long'];
+  months[10]['shortName'] = monthNames[10]['short'];
   months[10]['days'] = 31;
   months[11] = new Object();
-  months[11]['longName'] = Drupal.t('November');
-  months[11]['shortName'] = Drupal.t('Nov');
+  months[11]['longName'] = monthNames[11]['long'];
+  months[11]['shortName'] = monthNames[11]['short'];
   months[11]['days'] = 30;
   months[12] = new Object();
-  months[12]['longName'] = Drupal.t('December');
-  months[12]['shortName'] = Drupal.t('Dec');
+  months[12]['longName'] = monthNames[12]['long'];
+  months[12]['shortName'] = monthNames[12]['short'];
   months[12]['days'] = 31;
 
-  // Create an array containing weekday names.
-  var weekdays = new Array();
-  weekdays[0] = new Object();
-  weekdays[0]['longName'] = Drupal.t('Sunday');
-  weekdays[0]['shortName'] = Drupal.t('Sun');
-  weekdays[1] = new Object();
-  weekdays[1]['longName'] = Drupal.t('Monday');
-  weekdays[1]['shortName'] = Drupal.t('Mon');
-  weekdays[2] = new Object();
-  weekdays[2]['longName'] = Drupal.t('Tuesday');
-  weekdays[2]['shortName'] = Drupal.t('Tue');
-  weekdays[3] = new Object();
-  weekdays[3]['longName'] = Drupal.t('Wednesday');
-  weekdays[3]['shortName'] = Drupal.t('Wed');
-  weekdays[4] = new Object();
-  weekdays[4]['longName'] = Drupal.t('Thursday');
-  weekdays[4]['shortName'] = Drupal.t('Thu');
-  weekdays[5] = new Object();
-  weekdays[5]['longName'] = Drupal.t('Friday');
-  weekdays[5]['shortName'] = Drupal.t('Fri');
-  weekdays[6] = new Object();
-  weekdays[6]['longName'] = Drupal.t('Saturday');
-  weekdays[6]['shortName'] = Drupal.t('Sat');
+  // Week-related.
+  var weekday = date.getDay();
+  if (weekday == 0) {
+    var weekNumber = Math.floor((daysOfYear - 7) / 7) + 1;
+  }
+  else {
+    var weekNumber = Math.floor((daysOfYear - weekday) / 7) + 1;
+  }
+  var weekNumberLeadingZero = ((weekNumber < 10) ? '0' + weekNumber : weekNumber);
+  var weekdayLongName = weekdayNames[weekday]['long'];
+  var weekdayShortName = weekdayNames[weekday]['short'];
+
+  // Offset-related.
+  if (offsetSeconds < 0) {
+    var offsetPrefix = '-';
+    var offsetHours = Math.floor(parseInt(offsetSeconds.substr(1)) / 3600);
+    var offsetHoursLeadingZero = ((offsetHours < 10) ? '0' + offsetHours : offsetHours);
+    var offsetMinutes = (parseInt(offsetSeconds.substr(1)) / 60) % 60;
+    var offsetMinutesLeadingZero = ((offsetMinutes < 10) ? '0' + offsetMinutes : offsetMinutes);
+  }
+  else {
+    var offsetPrefix = '+';
+    var offsetHours = Math.floor(offsetSeconds) / 3600;
+    var offsetHoursLeadingZero = ((offsetHours < 10) ? '0' + offsetHours : offsetHours);
+    var offsetMinutes = (offsetSeconds / 60) % 60;
+    var offsetMinutesLeadingZero = ((offsetMinutes < 10) ? '0' + offsetMinutes : offsetMinutes);
+  }
 
+  // Hour-related.
+  var hours = date.getHours();
+  var hoursLeadingZero = ((hours < 10) ? '0' + hours : hours);
+  if (hours == 0) {
+    var hoursTwelve = (hours + 12);
+  }
+  else if (hours > 12) {
+    var hoursTwelve = (hours - 12);
+  }
+  else {
+    var hoursTwelve = hours;
+  }
+  var hoursTwelveLeadingZero = ((hoursTwelve < 10) ? '0' + hoursTwelve : hoursTwelve);
 
-  // Initialize the clock variable for later use.
-  var clock = '';
+  // Minute-related.
+  var minutes = date.getMinutes();
+  var minutesLeadingZero = ((minutes < 10) ? '0' + minutes : minutes);
+
+  // Second-related.
+  var seconds = date.getSeconds();
+  var secondsLeadingZero = ((seconds < 10) ? '0' + seconds : seconds);
+  var beats = Math.floor(((hours * 3600) + (minutes * 60) + seconds - parseInt(offsetSeconds) + 3600) / 86400 * 1000);
+  if (beats < 10) {
+    var beatsLeadingZero = ((beats < 10) ? '00' + beats : beats);
+  }
+  else if (beats < 100) {
+    var beatsLeadingZero = ((beats < 100) ? '0' + beats : beats);
+  }
+  else {
+    var beatsLeadingZero = beats;
+  }
+  var timestamp = date.getTime();
 
-  // Format a given date format string into a proper date string.
-  function formatDate(date, timestamp, dateFormat, timezoneOffsetSeconds, timezoneName, daylightSavingsTime, offsetName) {
-    // Initialize the 'formattedDate' variable for later use.
-    var formattedDate = '';
-
-    // Prepare variables for the format conversion.
-
-    // Year-related.
-    var year = date.getFullYear();
-    var yearShort = year % 100;
-
-    // Month-related.
-    var month = date.getMonth();
-    // JavaScript starts counting the months with 0 instead of 1.
-    month++;
-    var monthLeadingZero = ((month < 10) ? '0' + month : month);
-    var monthLongName = months[month]['longName'];
-    var monthShortName = months[month]['shortName'];
-
-    var day = date.getDate();
-    var dayLeadingZero = ((day < 10) ? '0' + day : day);
-    switch (day) {
-      case 1:
-        var dayOfMonthAppend = Drupal.t('st');
+  // Turn the date format string into an array so each character has its own key.
+  var dateFormat = dateFormat.split('');
+
+  // Perform the date format conversion for a character.
+  for (i=0; i < dateFormat.length; i++) {
+    switch (dateFormat[i]) {
+      // If the escape character '\' is used, simply return the following character.
+      case '\\':
+        formattedDate += dateFormatArray[++i];
+        break;
+      // 'am' or 'pm' depending on the time of day.
+      case 'a':
+        formattedDate += ((hours >= 12) ? Drupal.t('pm') : Drupal.t('am'));
+        break;
+      // 'AM' or 'PM' depending on the time of day.
+      case 'A':
+        formattedDate += ((hours >= 12) ? Drupal.t('PM') : Drupal.t('AM'));
+        break;
+      // Swatch-Internet-Time.
+      case 'B':
+        formattedDate += beatsLeadingZero;
+        break;
+      // ISO-8601 date.
+      case 'c':
+        formattedDate += year + '-' + monthLeadingZero + '-' + dayLeadingZero + 'T' + hoursLeadingZero + ':' + minutesLeadingZero + ':' + secondsLeadingZero + offsetPrefix + offsetHoursLeadingZero + ':' + offsetMinutesLeadingZero;
+        break;
+      // Day of month with leading zero, '01' - '31'.
+      case 'd':
+        formattedDate += dayLeadingZero;
+        break;
+      // Short name of weekday, e.g. 'Sun'.
+      case 'D':
+        formattedDate += weekdayShortName;
+        break;
+      // Time zone name, e.g. 'Europe/London';
+      case 'e':
+        formattedDate += timezoneName;
+        break;
+      // Name of month, e.g. 'January'.
+      case 'F':
+        formattedDate += monthLongName;
+        break;
+      // Hours in 12-hour format, '1' - '12'.
+      case 'g':
+        formattedDate += hoursTwelve;
+        break;
+      // Hours in 24-hour format, '0' - '23'.
+      case 'G':
+        formattedDate += hours;
+        break;
+      // Hours in 12-hour format with leading zero, '01' - '12'.
+      case 'h':
+        formattedDate += hoursTwelveLeadingZero;
+        break;
+      // Hours in 24-hour format with leading zero, '00' - '23'.
+      case 'H':
+        formattedDate += hoursLeadingZero;
+        break;
+      // Minutes with leading zero, '00' - '59'.
+      case 'i':
+        formattedDate += minutesLeadingZero;
+        break;
+      // Daylight Savings Time, '1' or '0'
+      case 'I':
+        formattedDate += daylightSavingsTime;
+        break;
+      // Day of month, '1' - '31'
+      case 'j':
+        formattedDate += day;
+        break;
+      // Name of weekday, e.g. 'Sunday'.
+      case 'l':
+        formattedDate += weekdayLongName;
+        break;
+      // Leap year, '1' or '0'.
+      case 'L':
+        formattedDate += leapYear;
         break;
-      case 2:
-        var dayOfMonthAppend = Drupal.t('nd');
+      // Number of month with leading zero, '01' - '12'
+      case 'm':
+        formattedDate += monthLeadingZero;
         break;
-      case 3:
-        var dayOfMonthAppend = Drupal.t('rd');
+      // Short name of month, e.g. 'Jan'.
+      case 'M':
+        formattedDate += monthShortName;
         break;
+      // Number of month, '1' - '12'.
+      case 'n':
+        formattedDate += month;
+        break;
+      // ISO-8601 weekday number, '1' - '7'.
+      case 'N':
+        formattedDate += weekday + 1;
+        break;
+      // ISO-8601 year number.
+      // This has a different value from 'Y' in certain constellations at the
+      // beginning or end of a year, but this is not implemented here.
+      case 'o':
+        formattedDate += year;
+        break;
+      // Time zone offset, e.g. '+1030'
+      case 'O':
+        formattedDate += offsetPrefix + offsetHoursLeadingZero + offsetMinutesLeadingZero;
+        break;
+      // Time zone offset, e.g. '+10:30'.
+      case 'P':
+        formattedDate += offsetPrefix + offsetHoursLeadingZero + ':' + offsetMinutesLeadingZero;
+        break;
+      // RFC-2822 date.
+      case 'r':
+        formattedDate += weekdayShortName + ', ' + dayLeadingZero + ' ' + monthShortName + ' ' + year + ' ' + hoursLeadingZero + ':' + minutesLeadingZero + ':' + secondsLeadingZero + ' ' + offsetPrefix + offsetHoursLeadingZero + offsetMinutesLeadingZero;
+        break;
+      // Seconds with leading zero.
+      case 's':
+        formattedDate += secondsLeadingZero;
+        break;
+      // Appendage for the day of month, e.g. 'st' if the day is '1'.
+      case 'S':
+        formattedDate += dayOfMonthAppend;
+        break;
+      // Total days of month, '28' - '31'.
+      case 't':
+        formattedDate += months[month]['days'];
+        break;
+      // Name of offset, e.g. 'GMT'.
+      case 'T':
+        formattedDate += offsetName;
+        break;
+      // Milliseconds since the begin of the UNIX-era.
+      case 'u':
+        formattedDate += timestamp;
+        break;
+      // Seconds since the begin of the UNIX-era.
+      case 'U':
+        formattedDate += timestamp / 1000;
+        break;
+      // Number of weekday, '0' for Sunday, ..., '6' for Saturday.
+      case 'w':
+        formattedDate += weekday;
+        break;
+      // ISO-8601 week number, '01' - '52'.
+      case 'W':
+        formattedDate += weekNumberLeadingZero;
+        break;
+      // Year, e.g. '2001'.
+      case 'Y':
+        formattedDate += year;
+        break;
+      // Short year, e.g. '01'.
+      case 'y':
+        formattedDate += yearShort;
+        break;
+      // Days of the year, '0' - '365'.
+      // Since PHP starts counting the days of the year at '0', we need subtract one.
+      case 'z':
+        formattedDate += daysOfYear - 1;
+        break;
+      // Time zone offset in seconds.
+      case 'Z':
+        formattedDate += offsetSeconds;
+        break;
+      // If the character is not a date formatter, just add it to the output.
       default:
-        var dayOfMonthAppend = Drupal.t('th');
+        formattedDate += dateFormatArray[i];
         break;
     }
-    // To calculate the days of the year, iterate through all passed months and then add the current days of the month.
-    var daysOfYear = 0;
-    for (var m = 1; m < month; m++) {
-      daysOfYear += months[m]['days'];
-    }
-    daysOfYear += day;
-
-    // Week-related.
-    var weekday = date.getDay();
-    if (weekday == 0) {
-      var weekNumber = Math.floor((daysOfYear - 7) / 7) + 1;
-    }
-    else {
-      var weekNumber = Math.floor((daysOfYear - weekday) / 7) + 1;
-    }
-    var weekNumberLeadingZero = ((weekNumber < 10) ? '0' + weekNumber : weekNumber);
-    var weekdayLongName = weekdays[weekday]['longName'];
-    var weekdayShortName = weekdays[weekday]['shortName'];
-
-    // Offset-related.
-    if (timezoneOffsetSeconds < 0) {
-      var offsetPrefix = '-';
-      var offsetHours = Math.floor(parseInt(timezoneOffsetSeconds.substr(1)) / 3600);
-      var offsetHoursLeadingZero = ((offsetHours < 10) ? '0' + offsetHours : offsetHours);
-      var offsetMinutes = (parseInt(timezoneOffsetSeconds.substr(1)) / 60) % 60;
-      var offsetMinutesLeadingZero = ((offsetMinutes < 10) ? '0' + offsetMinutes : offsetMinutes);
-    }
-    else {
-      var offsetPrefix = '+';
-      var offsetHours = Math.floor(timezoneOffsetSeconds) / 3600;
-      var offsetHoursLeadingZero = ((offsetHours < 10) ? '0' + offsetHours : offsetHours);
-      var offsetMinutes = (timezoneOffsetSeconds / 60) % 60;
-      var offsetMinutesLeadingZero = ((offsetMinutes < 10) ? '0' + offsetMinutes : offsetMinutes);
-    }
-
-    // Hour-related.
-    var hours = date.getHours();
-    var hoursLeadingZero = ((hours < 10) ? '0' + hours : hours);
-    if (hours == 0) {
-      var hoursTwelve = (hours + 12);
-    }
-    else if (hours > 12) {
-      var hoursTwelve = (hours - 12);
-    }
-    else {
-      var hoursTwelve = hours;
-    }
-    var hoursTwelveLeadingZero = ((hoursTwelve < 10) ? '0' + hoursTwelve : hoursTwelve);
-
-    // Minute-related.
-    var minutes = date.getMinutes();
-    var minutesLeadingZero = ((minutes < 10) ? '0' + minutes : minutes);
-
-    // Second-related.
-    var seconds = date.getSeconds();
-    var secondsLeadingZero = ((seconds < 10) ? '0' + seconds : seconds);
-    var beats = Math.floor(((hours * 3600) + (minutes * 60) + seconds - parseInt(timezoneOffsetSeconds) + 3600) / 86400 * 1000);
-    if (beats < 10) {
-      var beatsLeadingZero = ((beats < 10) ? '00' + beats : beats);
-    }
-    else if (beats < 100) {
-      var beatsLeadingZero = ((beats < 100) ? '0' + beats : beats);
-    }
-    else {
-      var beatsLeadingZero = beats;
-    }
-
-    // Turn the date format string into an array so each character has its own key.
-    var dateFormatParts = dateFormat.length;
-    var dateFormatArray = dateFormat.split('');
-
-    // Perform the date format conversion for a character.
-    for (i=0; i < dateFormatParts; i++) {
-      switch (dateFormatArray[i]) {
-        // If the escape character '\' is used, simply return the following character.
-        case '\\':
-          formattedDate += dateFormatArray[++i];
-          break;
-        // 'am' or 'pm' depending on the time of day.
-        case 'a':
-          formattedDate += ((hours >= 12) ? Drupal.t('pm') : Drupal.t('am'));
-          break;
-        // 'AM' or 'PM' depending on the time of day.
-        case 'A':
-          formattedDate += ((hours >= 12) ? Drupal.t('PM') : Drupal.t('AM'));
-          break;
-        // Swatch-Internet-Time.
-        case 'B':
-          formattedDate += beatsLeadingZero;
-          break;
-        // ISO-8601 date.
-        case 'c':
-          formattedDate += year + '-' + monthLeadingZero + '-' + dayLeadingZero + 'T' + hoursLeadingZero + ':' + minutesLeadingZero + ':' + secondsLeadingZero + offsetPrefix + offsetHoursLeadingZero + ':' + offsetMinutesLeadingZero;
-          break;
-        // Day of month with leading zero, '01' - '31'.
-        case 'd':
-          formattedDate += dayLeadingZero;
-          break;
-        // Short name of weekday, e.g. 'Sun'.
-        case 'D':
-          formattedDate += weekdayShortName;
-          break;
-        // Time zone name, e.g. 'Europe/London';
-        case 'e':
-          formattedDate += timezoneName;
-          break;
-        // Name of month, e.g. 'January'.
-        case 'F':
-          formattedDate += monthLongName;
-          break;
-        // Hours in 12-hour format, '1' - '12'.
-        case 'g':
-          formattedDate += hoursTwelve;
-          break;
-        // Hours in 24-hour format, '0' - '23'.
-        case 'G':
-          formattedDate += hours;
-          break;
-        // Hours in 12-hour format with leading zero, '01' - '12'.
-        case 'h':
-          formattedDate += hoursTwelveLeadingZero;
-          break;
-        // Hours in 24-hour format with leading zero, '00' - '23'.
-        case 'H':
-          formattedDate += hoursLeadingZero;
-          break;
-        // Minutes with leading zero, '00' - '59'.
-        case 'i':
-          formattedDate += minutesLeadingZero;
-          break;
-        // Daylight Savings Time, '1' or '0'
-        case 'I':
-          formattedDate += daylightSavingsTime;
-          break;
-        // Day of month, '1' - '31'
-        case 'j':
-          formattedDate += day;
-          break;
-        // Name of weekday, e.g. 'Sunday'.
-        case 'l':
-          formattedDate += weekdayLongName;
-          break;
-        // Leap year, '1' or '0'.
-        case 'L':
-          formattedDate += leapYear;
-          break;
-        // Number of month with leading zero, '01' - '12'
-        case 'm':
-          formattedDate += monthLeadingZero;
-          break;
-        // Short name of month, e.g. 'Jan'.
-        case 'M':
-          formattedDate += monthShortName;
-          break;
-        // Number of month, '1' - '12'.
-        case 'n':
-          formattedDate += month;
-          break;
-        // Time zone offset, e.g. '+1030'
-        case 'O':
-          formattedDate += offsetPrefix + offsetHoursLeadingZero + offsetMinutesLeadingZero;
-          break;
-        // Time zone offset, e.g. '+10:30'.
-        case 'P':
-          formattedDate += offsetPrefix + offsetHoursLeadingZero + ':' + offsetMinutesLeadingZero;
-          break;
-        // RFC-2822 date.
-        case 'r':
-          formattedDate += weekdayShortName + ', ' + dayLeadingZero + ' ' + monthShortName + ' ' + year + ' ' + hoursLeadingZero + ':' + minutesLeadingZero + ':' + secondsLeadingZero + ' ' + offsetPrefix + offsetHoursLeadingZero + offsetMinutesLeadingZero;
-          break;
-        // Seconds with leading zero.
-        case 's':
-          formattedDate += secondsLeadingZero;
-          break;
-        // Appendage for the day of month, e.g. 'st' if the day is '1'.
-        case 'S':
-          formattedDate += dayOfMonthAppend;
-          break;
-        // Total days of month, '28' - '31'.
-        case 't':
-          formattedDate += months[month]['days'];
-          break;
-        // Name of offset, e.g. 'GMT'.
-        case 'T':
-          formattedDate += offsetName;
-          break;
-        // Seconds since the begin of the UNIX-era.
-        // We have to divide by 1000 to get seconds, not milliseconds.
-        case 'U':
-          formattedDate += timestamp / 1000;
-          break;
-        // Number of weekday, '0' for Sunday, ..., '6' for Saturday.
-        case 'w':
-          formattedDate += weekday;
-          break;
-        // Week number with leading zero, '01' - '52'.
-        case 'W':
-          formattedDate += weekNumberLeadingZero;
-          break;
-        // Year, e.g. '2001'.
-        case 'Y':
-          formattedDate += year;
-          break;
-        // Short year, e.g. '01'.
-        case 'y':
-          formattedDate += yearShort;
-          break;
-        // Days of the year, '0' - '365'.
-        // Since PHP starts counting the days of the year at '0', we need subtract one.
-        case 'z':
-          formattedDate += daysOfYear - 1;
-          break;
-        // Time zone offset in seconds.
-        case 'Z':
-          formattedDate += timezoneOffsetSeconds;
-          break;
-        // If the character is not a date formatter, just add it to the output.
-        default:
-          formattedDate += dateFormatArray[i];
-          break;
-      }
-    }
-    return formattedDate;
   }
-
-  if (clockUpdate == '1' || clockTimezoneName == 'Local') {
-
-    // Format the clock.
-    if (clockTimezoneName == 'Local') {
-      var clockDate = new Date();
-    }
-    else {
-      var clockDate = new Date(clockTime);
-    }
-
-    var clockTimestamp = clockDate.getTime();
-
-    clock = formatDate(clockDate, clockTimestamp, clockDateFormat, clockTimezoneOffsetSeconds, clockTimezoneName, clockDaylightSavingsTime, clockOffsetName);
-    $('div.clock').html(clock);
-
-    if (clockUpdate == '1') {
-
-      // Recalculate the date every second. '.everyTime' is provided by jQuery Timers.
-      $(document).everyTime(1000, function() {
-
-        // Add 1 second to the timestamp.
-        clockTimestamp = clockTimestamp + 1000;
-        clockDate = new Date(clockTimestamp);
-
-        clock = formatDate(clockDate, clockTimestamp, clockDateFormat, clockTimezoneOffsetSeconds, clockTimezoneName, 1, clockOffsetName);
-
-        $('div.clock').html(clock);
-      }, 0);
-    }
-  }
-}
-
-/*
- * Hide the select boxes on the clock block configure screen if the specific options are disabled.
- */
-Drupal.behaviors.clockConfigure = function (context) {
-  // Show the custom time zone select list only when 'Custom time zone' is checked.
-  $('div.edit-custom-timezone').addClass('js-hide');
-  function customTimezoneSelect() {
-    var value = $('div.edit-timezone input:checked').val();
-    if (value == '4') {
-      $('div.edit-custom-timezone').show();
-    }
-    else {
-      $('div.edit-custom-timezone').hide();
-    }
-  }
-  $('div.edit-timezone').bind('click', customTimezoneSelect);
-  customTimezoneSelect();
-
-  // Show the custom date format select list only when 'Custom date format' is checked.
-  $('div.edit-custom-date-format').addClass('js-hide');
-  function customDateFormatSelect() {
-    var value = $('div.edit-date-format input:checked').val();
-    if (value == 'custom') {
-      $('div.edit-custom-date-format').show();
-    }
-    else {
-      $('div.edit-custom-date-format').hide();
-    }
-  }
-  $('div.edit-date-format').bind('click', customDateFormatSelect);
-  customDateFormatSelect();
+  return formattedDate;
 }
 
Index: clock.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.module,v
retrieving revision 1.9.2.7
diff -u -p -r1.9.2.7 clock.module
--- clock.module	11 Apr 2010 09:31:53 -0000	1.9.2.7
+++ clock.module	21 Apr 2010 19:28:09 -0000
@@ -1,12 +1,12 @@
 <?php
 // $Id: clock.module,v 1.9.2.7 2010/04/11 09:31:53 tstoeckler Exp $
 
-/*
+/**
  * @file
  * Functions to manage the display of a clock.
  */
 
-/*
+/**
  * Implements hook_help().
  */
 function clock_help($path, $arg) {
@@ -52,7 +52,7 @@ function clock_help($path, $arg) {
   }
 }
 
-/*
+/**
  * Implements hook_block().
  */
 function clock_block($op = 'list', $delta = 0, $edit = array()) {
@@ -193,7 +193,7 @@ function clock_block($op = 'list', $delt
   }
 }
 
-/*
+/**
  * Implements hook_theme.
  */
 function clock_theme() {
@@ -208,7 +208,7 @@ function clock_theme() {
   );
 }
 
-/*
+/**
  * Gets the correct time zone.
  *
  * @return
@@ -239,7 +239,7 @@ function clock_get_timezone() {
   return $timezone;
 }
 
-/*
+/**
  * Gets the correct date format.
  *
  * @return
@@ -262,14 +262,13 @@ function clock_get_date_format() {
   return $date_format;
 }
 
-/*
+/**
  * Formats a clock in HTML.
  */
 function theme_clock($timezone, $date_format, $js) {
   if ($js == '1' || $timezone == 'Local') {
 
     // Create variables that are needed for the JavaScript time calculation.
-
     // Create a time string.
     $time = date_format_date(date_make_date(date_now($timezone), $type = 'custom', $format = 'F j, Y H:i:s');
     // Get the time zone offset in seconds.
@@ -282,13 +281,13 @@ function theme_clock($timezone, $date_fo
 
     // Pass the variables to JavaScript.
     drupal_add_js(array(
-      '0' => $js,
-      '1' => $time,
-      '2' => $offset_seconds,
-      '3' => $timezone,
-      '4' => $daylight_savings_time,
-      '5' => $offset_name,
-      '6' => $date_format,
+      'js' => $js,
+      'time' => $time,
+      'offset_seconds' => $offset_seconds,
+      'timezone_name' => $timezone,
+      'daylight_savings_time' => $daylight_savings_time,
+      'offset_name' => $offset_name,
+      'date_format' => $date_format,
     ), 'setting');
 
 
@@ -313,3 +312,4 @@ function theme_clock($timezone, $date_fo
 
   return $output;
 }
+
