? worldclock_move_locations_to_db-d6.patch
Index: worldclock.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/worldclock/Attic/worldclock.install,v
retrieving revision 1.1.2.1.2.1
diff -r1.1.2.1.2.1 worldclock.install
5c5,13
<  * Implementation of hook_uninstall().
---
>  * Implementation of hook_install().
>  */
> function worldclock_install() {
>   drupal_install_schema('worldclock');
>   worldclock_load_locations();
> }
> 
> /**
>  * Implementation of hook_uninstall
8c16,17
<   variable_del('wc_location');
---
>   // Remove tables.
>   drupal_uninstall_schema('worldclock');
16a26,308
> 
> 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.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/worldclock/worldclock.module,v
retrieving revision 1.1.4.7.2.6
diff -r1.1.4.7.2.6 worldclock.module
14,152c14,23
< 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;
> }
158,166c29,32
<   // 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;
168c34
<   return $loc_array;
---
>   return $options;
174,175c40,41
< function _worldclock_get_location_info($loc) {
<   // in: $loc - location record array
---
> function _worldclock_get_location_info($location) {
>   // in: $loc - location record object
181,182c47,48
<   if ($loc[INDEX_GMT] >= 0) {
<     $output .= t('GMT +') . $loc[INDEX_GMT] .', ';
---
>   if ($location->gmt >= 0) {
>     $output .= t('GMT +') . $location->gmt .', ';
185c51
<     $output .= t('GMT ') . $loc[INDEX_GMT] .', ';
---
>     $output .= t('GMT ') . $location->gmt .', ';
187c53
<   if ($loc[INDEX_DST] == 0) {
---
>   if ($location->dst == 0) {
194,197c60,63
<                 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]));
199,202c65,68
<                 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]));
224d89
<   global $_worldclock_location;
244c109,110
<     $output = theme('clocks_list', $_worldclock_location, $maxnum, $showzebra, $timestr, $footnote);
---
>     $locations = _worldclock_get_locations();
>     $output = theme('clocks_list', $locations, $maxnum, $showzebra, $timestr, $footnote);
267c133,135
<         $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]));
289c157
<       '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),
298c166
< function theme_clocks_list($_worldclock_location, $maxnum, $showzebra, $timestr, $footnote) {
---
> function theme_clocks_list($locations, $maxnum, $showzebra, $timestr, $footnote) {
311,312c179
<       $loc = $_worldclock_location[$loc_no];
<       $loc_name  = $loc[INDEX_NAME];
---
>       $location = $locations[$loc_no];
314c181
<       $output .= '<td class="worldclock_location">'. $loc_name  .'</td>';
---
>       $output .= '<td class="worldclock_location">'. $location->name  .'</td>';
331,332d197
<   global $_worldclock_location;
< 
357c222,223
< 
---
>   
>   $locations = _worldclock_get_locations();
363c229
<       $loc = $_worldclock_location[$loc_no];
---
>       $loc = $locations[$loc_no];
535a402,418
> 
> /**
>  * 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;
> }
