version 1.48.2.1, 2008/09/20 01:57:50
|
version 1.49, 2008/09/19 03:27:04
|
Line 166 use locale;
|
Line 166 use locale;
|
use POSIX qw(locale_h strftime); |
use POSIX qw(locale_h strftime); |
use DateTime(); |
use DateTime(); |
use DateTime::TimeZone; |
use DateTime::TimeZone; |
|
use DateTime::Locale; |
|
|
require Exporter; |
require Exporter; |
|
|
Line 300 sub gettimezone {
|
Line 301 sub gettimezone {
|
$timezone = $domdefaults{'timezone_def'}; |
$timezone = $domdefaults{'timezone_def'}; |
} |
} |
} |
} |
} elsif ($Apache::lonnet::env{'request.role.domain'} ne '') { |
|
my %uroledomdefs = |
|
&Apache::lonnet::get_domain_defaults($Apache::lonnet::env{'request.role.domain'}); |
|
if ($uroledomdefs{'timezone_def'} ne '') { |
|
$timezone = $uroledomdefs{'timezone_def'}; |
|
} |
|
} elsif ($Apache::lonnet::env{'user.domain'} ne '') { |
|
my %udomdefaults = |
|
&Apache::lonnet::get_domain_defaults($Apache::lonnet::env{'user.domain'}); |
|
if ($udomdefaults{'timezone_def'} ne '') { |
|
$timezone = $udomdefaults{'timezone_def'}; |
|
} |
|
} |
} |
if ($timezone ne '') { |
if ($timezone ne '') { |
if (DateTime::TimeZone->is_valid_name($timezone)) { |
if (DateTime::TimeZone->is_valid_name($timezone)) { |
Line 378 sub locallocaltime {
|
Line 367 sub locallocaltime {
|
} |
} |
} |
} |
|
|
|
sub getdatelocale { |
|
my ($datelocale,$locale_obj); |
|
if ($Apache::lonnet::env{'course.'.$Apache::lonnet::env{'request.course.id'}.'.datelocale'}) { |
|
$datelocale = $Apache::lonnet::env{'course.'.$Apache::lonnet::env{'request.course.id'}.'.datelocale'}; |
|
} elsif ($Apache::lonnet::env{'request.course.id'} ne '') { |
|
my $cdom = $Apache::lonnet::env{'course.'.$Apache::lonnet::env{'request.course.id'}.'.domain'}; |
|
if ($cdom ne '') { |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
|
if ($domdefaults{'datelocale_def'} ne '') { |
|
$datelocale = $domdefaults{'datelocale_def'}; |
|
} |
|
} |
|
} elsif ($Apache::lonnet::env{'user.domain'} ne '') { |
|
my %udomdefaults = &Apache::lonnet::get_domain_defaults($Apache::lonnet::env{'user.domain'}); |
|
if ($udomdefaults{'datelocale_def'} ne '') { |
|
$datelocale = $udomdefaults{'datelocale_def'}; |
|
} |
|
} |
|
if ($datelocale ne '') { |
|
eval { |
|
$locale_obj = DateTime::Locale->load($datelocale); |
|
}; |
|
if (!$@) { |
|
if ($locale_obj->id() eq $datelocale) { |
|
return $locale_obj; |
|
} |
|
} |
|
} |
|
return $locale_obj; |
|
} |
|
|
|
|
# ==================== Normalize string (reduce fragility in the lexicon files) |
# ==================== Normalize string (reduce fragility in the lexicon files) |
|
|
# This normalizes a string to reduce fragility in the lexicon files of |
# This normalizes a string to reduce fragility in the lexicon files of |