[Rt-commit] rt branch, admin_ui, updated. e0bb54c217afafeff743b9d97b443f1f16006f1a
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Fri Jan 22 01:13:11 EST 2010
The branch, admin_ui has been updated
via e0bb54c217afafeff743b9d97b443f1f16006f1a (commit)
from 8be9735b2cf194f26f7e69267a2a963f2f3cf6d2 (commit)
Summary of changes:
lib/RT/Model/User.pm | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit e0bb54c217afafeff743b9d97b443f1f16006f1a
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jan 22 14:13:03 2010 +0800
make time_zone select
diff --git a/lib/RT/Model/User.pm b/lib/RT/Model/User.pm
index bbd9dc6..9ed9f05 100755
--- a/lib/RT/Model/User.pm
+++ b/lib/RT/Model/User.pm
@@ -124,7 +124,10 @@ use Jifty::DBI::Record schema {
column zip => max_length is 16, type is 'varchar(16)', default is '';
column country => type is 'varchar(50)', max_length is 50,
display_length is 20, default is '';
- column time_zone => type is 'varchar(50)', max_length is 50, default is '';
+ column time_zone => type is 'varchar(50)', max_length is 50, default is
+ '',
+ render as 'Select',
+ valid_values are lazy { formatted_timezones() };
column pgp_key => type is 'text';
};
@@ -1344,4 +1347,32 @@ sub basic_columns {
}
+sub formatted_timezones {
+ my @positive;
+ my @negative;
+ for my $tz ( DateTime::TimeZone->all_names ) {
+ my $now = DateTime->now( time_zone => $tz );
+ my $offset = $now->strftime("%z");
+ my $zone_data = { offset => $offset, name => $tz };
+ if ($offset =~ /^-/) {
+ push @negative, $zone_data;
+ } else {
+ push @positive, $zone_data;
+ }
+ }
+
+
+ @negative = sort { $b->{offset} cmp $a->{offset} ||
+ $a->{name} cmp $b->{name} } @negative;
+ @positive = sort { $a->{offset} cmp $b->{offset} ||
+ $a->{name} cmp $b->{name} } @positive;;
+
+ return [
+ { display => _('system_default'), value => '' },
+ map { { display => "$_->{offset} $_->{name}", value => $_->{name} } }
+ ( @negative, @positive )
+ ];
+
+}
+
1;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list