Set up more sensible defaults (UTC, DST off) for timezone preferences. Also modified enano_date() to properly include GMT offsets when timezone characters are used. Fixes issue 4.
--- a/includes/functions.php Sat Dec 12 15:39:36 2009 -0500
+++ b/includes/functions.php Sat Dec 12 15:43:23 2009 -0500
@@ -348,10 +348,34 @@
// are we in DST?
global $dst_params;
+ $dst_offset = 0;
if ( check_timestamp_dst($timestamp, $dst_params[0], $dst_params[1], $dst_params[2], $dst_params[3]) )
{
// offset for DST
$timestamp += ( $dst_params[4] * 60 );
+ $dst_offset = $dst_params[4];
+ }
+
+ // Does this date string include a timezone? If so, gmdate() will report UTC, which is wrong
+ // FIXME This is kind of a halfass replacement...
+ foreach ( array('e', 'T', 'O', 'P') as $char )
+ {
+ if ( ($pos = strpos($string, $char)) !== false )
+ {
+ if ( $string{ $pos - 1 } != '\\' )
+ {
+ // add in our own timezone string
+ // FIXME: l10n? (do we need to? does anyone really not know what "GMT" means? even uglier escaping?)
+ $tzi = '\\G\\M\\T';
+ $tzo = $timezone + $dst_offset;
+ $sign = $tzo > 0 ? '+' : '-';
+ $tzi .= $sign . (intval(abs($tzo / 60)));
+ if ( $tzo % 60 )
+ $tzi .= sprintf(":%02d", abs($tzo) % 60);
+
+ $string = substr($string, 0, $pos) . $tzi . substr($string, $pos + 1);
+ }
+ }
}
// Let PHP do the work for us =)
--- a/install/schemas/mysql_stage2.sql Sat Dec 12 15:39:36 2009 -0500
+++ b/install/schemas/mysql_stage2.sql Sat Dec 12 15:43:23 2009 -0500
@@ -116,7 +116,7 @@
user_registration_ip varchar(39),
user_rank int(12) UNSIGNED DEFAULT NULL,
user_rank_userset tinyint(1) NOT NULL DEFAULT 0,
- user_timezone int(12) UNSIGNED NOT NULL DEFAULT 0,
+ user_timezone int(12) UNSIGNED NOT NULL DEFAULT 1440,
user_title varchar(64) DEFAULT NULL,
user_group mediumint(5) NOT NULL DEFAULT 1,
user_dst varchar(11) NOT NULL DEFAULT '0;0;0;0;60',
--- a/install/schemas/postgresql_stage2.sql Sat Dec 12 15:39:36 2009 -0500
+++ b/install/schemas/postgresql_stage2.sql Sat Dec 12 15:43:23 2009 -0500
@@ -116,7 +116,7 @@
user_registration_ip varchar(39),
user_rank int DEFAULT NULL,
user_rank_userset smallint NOT NULL DEFAULT 0,
- user_timezone int NOT NULL DEFAULT 0,
+ user_timezone int NOT NULL DEFAULT 1440,
user_title varchar(64) DEFAULT NULL,
user_group int NOT NULL DEFAULT 1,
user_dst varchar(11) NOT NULL DEFAULT '0;0;0;0;60',
--- a/install/schemas/upgrade/1.1.1-1.1.2-mysql.sql Sat Dec 12 15:39:36 2009 -0500
+++ b/install/schemas/upgrade/1.1.1-1.1.2-mysql.sql Sat Dec 12 15:43:23 2009 -0500
@@ -5,7 +5,7 @@
ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN is_draft tinyint(1) NOT NULL DEFAULT 0;
ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank int(12) UNSIGNED NOT NULL DEFAULT 1;
-ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_timezone int(12) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_timezone int(12) UNSIGNED NOT NULL DEFAULT 1440;
@ALTER TABLE {{TABLE_PREFIX}}tags CHANGE user user_id mediumint(8) NOT NULL DEFAULT 1;
ALTER TABLE {{TABLE_PREFIX}}themes
--- a/install/schemas/upgrade/1.1.1-1.1.2-postgresql.sql Sat Dec 12 15:39:36 2009 -0500
+++ b/install/schemas/upgrade/1.1.1-1.1.2-postgresql.sql Sat Dec 12 15:43:23 2009 -0500
@@ -6,7 +6,7 @@
ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank int NOT NULL DEFAULT 1;
@ALTER TABLE {{TABLE_PREFIX}}users DROP user_timezone;
-ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_timezone int NOT NULL DEFAULT 0;
+ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_timezone int NOT NULL DEFAULT 1440;
ALTER TABLE {{TABLE_PREFIX}}themes
ADD COLUMN group_list text DEFAULT NULL,