version 1.52, 2008/11/28 14:36:55
|
version 1.53, 2009/01/02 23:07:52
|
Line 340 sub get_language_handle {
|
Line 340 sub get_language_handle {
|
|
|
# ========================================================== Localize localtime |
# ========================================================== Localize localtime |
sub gettimezone { |
sub gettimezone { |
my $timezone; |
my ($timezone) = @_; |
if ($Apache::lonnet::env{'course.'.$Apache::lonnet::env{'request.course.id'}.'.timezone'}) { |
if ($timezone ne '') { |
$timezone = $Apache::lonnet::env{'course.'.$Apache::lonnet::env{'request.course.id'}.'.timezone'}; |
if (!DateTime::TimeZone->is_valid_name($timezone)) { |
} elsif ($Apache::lonnet::env{'request.course.id'} ne '') { |
$timezone = 'local'; |
my $cdom = $Apache::lonnet::env{'course.'.$Apache::lonnet::env{'request.course.id'}.'.domain'}; |
} |
if ($cdom ne '') { |
return $timezone; |
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
} |
if ($domdefaults{'timezone_def'} ne '') { |
my $cid = $Apache::lonnet::env{'request.course.id'}; |
$timezone = $domdefaults{'timezone_def'}; |
if ($cid ne '') { |
|
if ($Apache::lonnet::env{'course.'.$cid.'.timezone'}) { |
|
$timezone = $Apache::lonnet::env{'course.'.$cid.'.timezone'}; |
|
} else { |
|
my $cdom = $Apache::lonnet::env{'course.'.$cid.'.domain'}; |
|
if ($cdom ne '') { |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
|
if ($domdefaults{'timezone_def'} ne '') { |
|
$timezone = $domdefaults{'timezone_def'}; |
|
} |
} |
} |
} |
} |
} elsif ($Apache::lonnet::env{'request.role.domain'} ne '') { |
} elsif ($Apache::lonnet::env{'request.role.domain'} ne '') { |
Line 373 sub gettimezone {
|
Line 382 sub gettimezone {
|
} |
} |
|
|
sub locallocaltime { |
sub locallocaltime { |
my $thistime=shift; |
my ($thistime,$timezone) = @_; |
if (!defined($thistime) || $thistime eq '') { |
if (!defined($thistime) || $thistime eq '') { |
return &mt('Never'); |
return &mt('Never'); |
} |
} |
Line 387 sub locallocaltime {
|
Line 396 sub locallocaltime {
|
} |
} |
|
|
my $dt = DateTime->from_epoch(epoch => $thistime) |
my $dt = DateTime->from_epoch(epoch => $thistime) |
->set_time_zone(&gettimezone()); |
->set_time_zone(&gettimezone($timezone)); |
if ((¤t_language=~/^en/) || (!$lh)) { |
if ((¤t_language=~/^en/) || (!$lh)) { |
|
|
return $dt->strftime("%a %b %e %I:%M:%S %P %Y (%Z)"); |
return $dt->strftime("%a %b %e %I:%M:%S %P %Y (%Z)"); |