Index: worldclock.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/worldclock/Attic/worldclock.install,v
retrieving revision 1.1.2.1.2.1
diff -u -F^f -r1.1.2.1.2.1 worldclock.install
--- worldclock.install	15 Dec 2008 11:17:12 -0000	1.1.2.1.2.1
+++ worldclock.install	18 Dec 2008 14:47:42 -0000
@@ -2,10 +2,19 @@
 // $Id: worldclock.install,v 1.1.2.1.2.1 2008/12/15 11:17:12 flevour Exp $
 /**
  * @file
- * Implementation of hook_uninstall().
+ * Implementation of hook_install().
+ */
+function worldclock_install() {
+  drupal_install_schema('worldclock');
+  worldclock_load_locations();
+}
+
+/**
+ * Implementation of hook_uninstall
  */
 function worldclock_uninstall() {
-  variable_del('wc_location');
+  // Remove tables.
+  drupal_uninstall_schema('worldclock');
 
   // delete all related variables from db: use query instead of a series of
   // variable_del's to remove all possible worldclock_location_*
@@ -14,3 +23,286 @@ function worldclock_uninstall() {
     variable_del($variable->name);
   }
 }
+
+function worldclock_update_6200(){
+  $schema['worldclock_locations'] = array(
+    'fields' => array(
+      'wid' => array(
+        'type' => 'serial',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'name' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'gmt' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'dst' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      's_mon' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      's_nth' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      's_dow' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      's_time' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'e_mon' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'e_nth' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'e_dow' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'e_time' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),   
+    ),
+    'primary key' => array('wid')
+  );
+  $ret = array();
+  db_create_table($ret, 'worldclock_locations', $schema['worldclock_locations']);  // THIS IS SAFE BECAUSE $schema IS EXPLICIT
+  worldclock_load_locations();
+  variable_del('wc_location'); // remove wc_location from older installations of 1.x
+  return $ret;
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function worldclock_schema() {
+  $schema['worldclock_locations'] = array(
+    'fields' => array(
+      'wid' => array(
+        'type' => 'serial',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'name' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'gmt' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'dst' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      's_mon' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      's_nth' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      's_dow' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      's_time' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'e_mon' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'e_nth' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'e_dow' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),
+      'e_time' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'size' => 'tiny',
+      ),   
+    ),
+    'primary key' => array('wid')
+  );
+
+  return $schema;
+}
+
+function worldclock_load_locations() {
+  // Note: wc_location array
+  //
+  //    Name      Country or area name
+  //    GMT Diff    GMT time difference -12 to +12 (can be decimal numbers)
+  //    DST Y/N     0=No DST, 1=Has DST
+  //    DST Start   Describes when the DST starts
+  //        Mon   1 to 12 (0 is used for no DST countries)
+  //        Nth   1=1st, 2=2nd, 3=3rd, 9=Last
+  //        DOW   Day of the week (0=Sun, 1=Mon, 2=Tue... 6=Sat)
+  //        Time  0=0:00AM, 1=1:00AM, 2=2:00AM.....
+  //    DST End     Describes when the DST ends
+  //        Mon   1 to 12 (0 is used for no DST countries)
+  //        Nth   1=1st, 2=2nd, 3=3rd, 9=Last
+  //        DOW   Day of the week (0=Sun, 1=Mon, 2=Tue... 6=Sat)
+  //        Time  0=0:00AM, 1=1:00AM, 2=2:00AM.....
+  //
+  $locations = array(
+    //     Name                 GMT  DST ----- Start ------  ------ End -------
+    //                          Diff Y/N  Mon Nth DOW Time    Mon Nth DOW Time
+    array( t('Afghanistan'),    4.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Argentina'),       -3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Australia ET'),    10,  1,  10,  9,  0,   2,     3,  9,  0,   3 ),
+    array( t('Australia CT'),   9.5,  1,  10,  9,  0,   2,     3,  9,  0,   3 ),
+    array( t('Australia WT'),     8,  1,  10,  9,  0,   2,     3,  9,  0,   3 ),
+    array( t('Austria'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Bangladesh'),       6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Belgium'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Bhutan'),           6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Bolivia'),         -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Brazil'),          -3,  1,  10,  3,  0,   0,     2,  3,  0,   0 ),
+    array( t('Bulgaria'),         2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Cambodia'),         7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Cameroon'),         1,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Canada AB'),       -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada BC'),       -8,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada MB'),       -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada NB'),       -4,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada NF'),     -3.5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada NT'),       -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada NS'),       -4,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada NU(M)'),    -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada NU(C)'),    -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada NU(E)'),    -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada ON(E)'),    -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada ON(W)'),    -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada PE'),       -4,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada QC'),       -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Canada QC(E)'),    -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Canada SK'),       -7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Canada SK(L)'),    -6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Canada YK'),       -8,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Chile'),           -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('China'),            8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Colombia'),        -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Costa Rica'),      -6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Croatia'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Czech Republic'),   1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Denmark'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Ecuador'),         -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Egypt'),            2,  1,   4,  9,  5,   0,     9,  9,  4,   0 ),
+    array( t('Ethiopia'),         3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Fiji'),            12,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Finland'),          2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('France'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Germany'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Ghana'),            0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Greece'),           2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Hungary'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Iceland'),          0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('India'),          5.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Iran'),           3.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Israel'),           2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Italy'),            1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Japan'),            9,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Jordan'),           2,  1,   3,  9,  4,   0,    10,  9,  5,   1 ),
+    array( t('Kenya'),            3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Korea'),            9,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Laos'),             7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Libya'),            2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Madagascar'),       3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Malaysia'),         8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Mauritius'),        4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Monaco'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Mongolia'),         8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Morocco'),          0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Myanmar'),        6.3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Nepal'),         5.45,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Netherland'),       1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('New Caledonia'),   11,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('New Zealand'),     12,  1,   9,  9,  0,   2,     4,  1,  0,   3 ),
+    array( t('Nigeria'),          1,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Norway'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Oman'),             4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Pakistan'),         5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Panama'),          -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Peru'),            -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Philippines'),      8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Porland'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Portugal'),         0,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Romania'),          2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Rwanda'),           2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Russia Moscow'),    3,  1,   3,  9,  0,   2,    10,  9,  0,   3 ),
+    array( t('Saudi Arabia'),     3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Senegal'),          0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Seychells'),        4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Singapore'),        8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('South Africa'),     2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Spain'),            1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Sudan'),            3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Sweden'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Switherland'),      1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('Taiwan'),           8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Thailand'),         7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Tonga'),           13,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Turkey'),           2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('UK'),               0,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
+    array( t('USA Alaska'),      -9,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('USA Hawaii'),     -10,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('USA PT'),          -8,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('USA MT'),          -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('USA CT'),          -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('USA ET'),          -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
+    array( t('Venezuela'),       -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Vietnam'),          7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+    array( t('Zambia'),           2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
+  );
+
+  //Preload the database with the locations
+  foreach ($locations as $id => $loc) {
+    db_query("INSERT INTO {worldclock_locations} (`wid`, `name`, `gmt`, `dst`, `s_mon`, `s_nth`, `s_dow`, `s_time`, `e_mon`, `e_nth`, `e_dow`, `e_time`) VALUES (%d, '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", ($id + 1), $loc[0], $loc[1], $loc[2], $loc[3], $loc[4], $loc[5], $loc[6], $loc[7], $loc[8], $loc[9], $loc[10], $loc[11]);
+  }
+}
+
Index: worldclock.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/worldclock/worldclock.js,v
retrieving revision 1.1.4.4.2.1
diff -u -F^f -r1.1.4.4.2.1 worldclock.js
--- worldclock.js	16 Dec 2008 17:29:46 -0000	1.1.4.4.2.1
+++ worldclock.js	18 Dec 2008 14:47:42 -0000
@@ -78,8 +78,7 @@ function DisplayClock(maxnum, time_str, 
 			}
 		}
 		idname = "worldclock" + i;
-		document.getElementById(idname).innerHTML 
-			= GenerateTimeString(diff, time_str) + out_dst_str;
+		document.getElementById(idname).innerHTML = GenerateTimeString(diff, time_str) + out_dst_str;
 	}
 	timerId = setTimeout("DisplayClock(Drupal.settings.maxnum, Drupal.settings.time_str, Drupal.settings.show_dst, Drupal.settings.dst_str, Drupal.settings.locations)", delay);
 }
Index: worldclock.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/worldclock/worldclock.module,v
retrieving revision 1.1.4.7.2.6
diff -u -F^f -r1.1.4.7.2.6 worldclock.module
--- worldclock.module	16 Dec 2008 17:29:46 -0000	1.1.4.7.2.6
+++ worldclock.module	18 Dec 2008 14:47:43 -0000
@@ -11,195 +11,61 @@
  *
  */
 
-define("INDEX_NAME",   0);
-define("INDEX_GMT",    1);
-define("INDEX_DST",    2);
-define("INDEX_SMON",   3);
-define("INDEX_SNTH",   4);
-define("INDEX_SDOW",   5);
-define("INDEX_STIME",  6);
-define("INDEX_EMON",   7);
-define("INDEX_ENTH",   8);
-define("INDEX_EDOW",   9);
-define("INDEX_ETIME", 10);
-
-  // Note: wc_location array
-  //
-  //    Name      Country or area name
-  //    GMT Diff    GMT time difference -12 to +12 (can be decimal numbers)
-  //    DST Y/N     0=No DST, 1=Has DST
-  //    DST Start   Describes when the DST starts
-  //        Mon   1 to 12 (0 is used for no DST countries)
-  //        Nth   1=1st, 2=2nd, 3=3rd, 9=Last
-  //        DOW   Day of the week (0=Sun, 1=Mon, 2=Tue... 6=Sat)
-  //        Time  0=0:00AM, 1=1:00AM, 2=2:00AM.....
-  //    DST End     Describes when the DST ends
-  //        Mon   1 to 12 (0 is used for no DST countries)
-  //        Nth   1=1st, 2=2nd, 3=3rd, 9=Last
-  //        DOW   Day of the week (0=Sun, 1=Mon, 2=Tue... 6=Sat)
-  //        Time  0=0:00AM, 1=1:00AM, 2=2:00AM.....
-  //
-  $GLOBALS['_worldclock_location'] = array(
-    //     Name                 GMT  DST ----- Start ------  ------ End -------
-    //                          Diff Y/N  Mon Nth DOW Time    Mon Nth DOW Time
-    array( t('-Not Selected-'),   0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Afghanistan'),    4.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Argentina'),       -3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Australia ET'),    10,  1,  10,  9,  0,   2,     3,  9,  0,   3 ),
-    array( t('Australia CT'),   9.5,  1,  10,  9,  0,   2,     3,  9,  0,   3 ),
-    array( t('Australia WT'),     8,  1,  10,  9,  0,   2,     3,  9,  0,   3 ),
-    array( t('Austria'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Bangladesh'),       6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Belgium'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Bhutan'),           6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Bolivia'),         -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Brazil'),          -3,  1,  10,  3,  0,   0,     2,  3,  0,   0 ),
-    array( t('Bulgaria'),         2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Cambodia'),         7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Cameroon'),         1,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Canada AB'),       -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada BC'),       -8,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada MB'),       -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NB'),       -4,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NF'),     -3.5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NT'),       -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NS'),       -4,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NU(M)'),    -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NU(C)'),    -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NU(E)'),    -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada ON(E)'),    -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada ON(W)'),    -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada PE'),       -4,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada QC'),       -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada QC(E)'),    -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Canada SK'),       -7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Canada SK(L)'),    -6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Canada YK'),       -8,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Chile'),           -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('China'),            8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Colombia'),        -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Costa Rica'),      -6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Croatia'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Czech Republic'),   1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Denmark'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Ecuador'),         -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Egypt'),            2,  1,   4,  9,  5,   0,     9,  9,  4,   0 ),
-    array( t('Ethiopia'),         3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Fiji'),            12,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Finland'),          2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('France'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Germany'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Ghana'),            0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Greece'),           2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Hungary'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Iceland'),          0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('India'),          5.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Iran'),           3.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Israel'),           2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Italy'),            1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Japan'),            9,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Jordan'),           2,  1,   3,  9,  4,   0,    10,  9,  5,   1 ),
-    array( t('Kenya'),            3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Korea'),            9,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Laos'),             7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Libya'),            2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Madagascar'),       3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Malaysia'),         8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Mauritius'),        4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Monaco'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Mongolia'),         8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Morocco'),          0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Myanmar'),        6.3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Nepal'),         5.45,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Netherlands'),       1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('New Caledonia'),   11,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('New Zealand'),     12,  1,   9,  9,  0,   2,     4,  1,  0,   3 ),
-    array( t('Nigeria'),          1,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Norway'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Oman'),             4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Pakistan'),         5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Panama'),          -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Peru'),            -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Philippines'),      8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Porland'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Portugal'),         0,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Romania'),          2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Rwanda'),           2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Russia Moscow'),    3,  1,   3,  9,  0,   2,    10,  9,  0,   3 ),
-    array( t('Saudi Arabia'),     3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Senegal'),          0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Seychells'),        4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Singapore'),        8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('South Africa'),     2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Spain'),            1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Sudan'),            3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Sweden'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Switzerland'),      1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Taiwan'),           8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Thailand'),         7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Tonga'),           13,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Turkey'),           2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('UK'),               0,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('USA Alaska'),      -9,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('USA Hawaii'),     -10,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('USA PT'),          -8,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('USA MT'),          -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('USA CT'),          -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('USA ET'),          -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Venezuela'),       -4.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Vietnam'),          7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Zambia'),           2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-  );
+function _worldclock_get_locations() {
+  static $locations = array();
+  if (empty($locations)) {
+    $result = db_query("SELECT * FROM {worldclock_locations} ORDER BY name");
+    while($row = db_fetch_object($result)) {
+      $locations[$row->wid] = $row;
+    }
+  }
+  return $locations;
+}
 
 /**
  * Construct an array for location pulldown menu
  */
 function _worldclock_get_location_options() {
-  // add this array to $GLOBALS so that other functions can access it
-  global $_worldclock_location;
-  $loc_array = array();
-
-  $numitems = count($_worldclock_location);
-  for ($i = 0 ; $i < $numitems ; $i++) {
-    $loc = $_worldclock_location[$i];
-    $loc_name = $loc[INDEX_NAME];
-    $loc_array[] = $loc_name;
+  $locations = _worldclock_get_locations();
+  $options[0] = t('-Not Selected-');
+  foreach($locations as $location) {
+    $options[$location->wid] = $location->name;
   }
-  return $loc_array;
+  return $options;
 }
 
 /**
  * Construct location information text string
  */
-function _worldclock_get_location_info($loc) {
-  // in: $loc - location record array
+function _worldclock_get_location_info($location) {
+  // in: $loc - location record object
   $nth_array = array('', t('1st '), t('2nd '), t('3rd '), t('4th '), '', '', '', '', t('last '));
   $dow_array = array(t('Sunday'), t('Monday'), t('Tuesday'), t('Wednesday'), t('Thursday'), t('Friday'), t('Saturday'));
   $mon_array = array('', t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December'));
 
   $output = '';
-  if ($loc[INDEX_GMT] >= 0) {
-    $output .= t('GMT +') . $loc[INDEX_GMT] .', ';
+  if ($location->gmt >= 0) {
+    $output .= t('GMT +') . $location->gmt .', ';
   }
   else {
-    $output .= t('GMT ') . $loc[INDEX_GMT] .', ';
+    $output .= t('GMT ') . $location->gmt .', ';
   }
-  if ($loc[INDEX_DST] == 0) {
+  if ($location->dst == 0) {
     $output .= t('No DST ');
   }
   else {
     $output .= t('DST ');
     // now add DST start and end information
     $output .= t(' from !stime:00AM on !snth !sdow in !smonth',
-                array('!stime'  => $loc[INDEX_STIME],
-                      '!snth'   => $nth_array[$loc[INDEX_SNTH]],
-                      '!sdow'   => $dow_array[$loc[INDEX_SDOW]],
-                      '!smonth' => $mon_array[$loc[INDEX_SMON]]));
+                array('!stime'  => $location->stime,
+                      '!snth'   => $nth_array[$location->snth],
+                      '!sdow'   => $dow_array[$location->sdow],
+                      '!smonth' => $mon_array[$location->smon]));
     $output .= t(' to !etime:00AM on !enth !edow in !emonth',
-                array('!etime'  => $loc[INDEX_ETIME],
-                      '!enth'   => $nth_array[$loc[INDEX_ENTH]],
-                      '!edow'   => $dow_array[$loc[INDEX_EDOW]],
-                      '!emonth' => $mon_array[$loc[INDEX_EMON]]));
+                array('!etime'  => $location->etime,
+                      '!enth'   => $nth_array[$location->enth],
+                      '!edow'   => $dow_array[$location->edow],
+                      '!emonth' => $mon_array[$location->emon]));
   }
   return $output;
 }
@@ -221,7 +87,6 @@ function worldclock_help($path, $arg) {
  * Implementation of hook_block().
  */
 function worldclock_block($op = 'list', $delta = 0) {
-  global $_worldclock_location;
   if ($op == 'list') {
     $block[0]['info'] = t('World Clock');
     return $block;
@@ -241,7 +106,8 @@ function worldclock_block($op = 'list', 
     }
 
     // output block content
-    $output = theme('clocks_list', $_worldclock_location, $maxnum, $showzebra, $timestr, $footnote);
+    $locations = _worldclock_get_locations();
+    $output = theme('clocks_list', $locations, $maxnum, $showzebra, $timestr, $footnote);
 
     // set javascript settings
     $settings['locations'] = array();
@@ -264,7 +130,9 @@ function worldclock_block($op = 'list', 
       $loc_no = variable_get('worldclock_location_'. $j, 0);
       // get the location record
       if ($loc_no > 0) {
-        $settings['locations'][$j] = array_merge(array($loc_no), $_worldclock_location[$loc_no]);
+        // JS expects arrays and we have an object: temporarily transform the location
+        // object to array so there's no need to change JS
+        $settings['locations'][$j] = array_merge(array($loc_no), _worldclock_object_to_array($locations[$loc_no]));
       }
     }
     
@@ -286,7 +154,7 @@ function worldclock_block($op = 'list', 
 function worldclock_theme() {
   return array(
     'clocks_list' => array(
-      'arguments' => array('wc_location' => NULL, 'maxnum' => NULL, 'showzebra' => NULL, 'timestr' => NULL, 'footnote' => NULL),
+      'arguments' => array('locations' => NULL, 'maxnum' => NULL, 'showzebra' => NULL, 'timestr' => NULL, 'footnote' => NULL),
     ),
   );
 }
@@ -295,7 +163,7 @@ function worldclock_theme() {
  * Theming function for block
  */
 
-function theme_clocks_list($_worldclock_location, $maxnum, $showzebra, $timestr, $footnote) {
+function theme_clocks_list($locations, $maxnum, $showzebra, $timestr, $footnote) {
   $output = '';
   // output table HTML
   $tr_class = '';
@@ -308,10 +176,9 @@ function theme_clocks_list($_worldclock_
     $loc_no = variable_get('worldclock_location_'. $j, 0);
     if ($loc_no > 0) {
       // get location name
-      $loc = $_worldclock_location[$loc_no];
-      $loc_name  = $loc[INDEX_NAME];
+      $location = $locations[$loc_no];
       $output .= '<tr class="'. $tr_class .'">';
-      $output .= '<td class="worldclock_location">'. $loc_name  .'</td>';
+      $output .= '<td class="worldclock_location">'. $location->name  .'</td>';
       $output .= '<td class="worldclock_time">';
       $output .= '<span id="worldclock'. $j .'"></span></td>';
       $output .= '</tr>';
@@ -328,8 +195,6 @@ function theme_clocks_list($_worldclock_
  * Module settings (admin page)
  */
 function worldclock_admin() {
-  global $_worldclock_location;
-
   $maxnum  = variable_get('worldclock_maxnum', 4);
   $format  = variable_get('worldclock_format', 'm/d h:i A');
   $timestr = variable_get('worldclock_timestr', 'm/d h:i A');
@@ -354,13 +219,14 @@ function worldclock_admin() {
     '#type' => 'markup',
     '#value' => t('You may leave the location unselected if you do not need to display the time.'),
   );
-
+  
+  $locations = _worldclock_get_locations();
   for ($j = 1 ; $j <= $maxnum ; $j++) {
     // show some information
     $loc_no = variable_get('worldclock_location_'. $j, 0);
     $loc_info = '';
     if ($loc_no) {
-      $loc = $_worldclock_location[$loc_no];
+      $loc = $locations[$loc_no];
       $loc_info = _worldclock_get_location_info($loc);
     }
     // create a pull-down menu
@@ -533,3 +399,20 @@ function worldclock_menu() {
 function worldclock_init() {
   drupal_add_js(drupal_get_path('module', 'worldclock') .'/worldclock.js');
 }
+
+/**
+ * Temporary function to transform a location database object to the legacy
+ * array structure v1 used.
+ */
+function _worldclock_object_to_array($object) {
+  // we get an associative array
+  $array = get_object_vars($object);
+  // we want to get the legacy numeric-keyed array, so remove the extra wid
+  // attribute and create new array taking values in order
+  unset($array['wid']);
+  $return = array();
+  foreach($array as $item) {
+    $return[] = $item;
+  }
+  return $return;
+}
