--- loncom/localize/lonlocal.pm 2020/10/29 23:04:39 1.68 +++ loncom/localize/lonlocal.pm 2022/09/08 01:41:14 1.69 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Localization routines # -# $Id: lonlocal.pm,v 1.68 2020/10/29 23:04:39 raeburn Exp $ +# $Id: lonlocal.pm,v 1.69 2022/09/08 01:41:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -363,7 +363,25 @@ sub gettimezone { } return $timezone; } - my $cid = $Apache::lonnet::env{'request.course.id'}; + my $cid = $Apache::lonnet::env{'request.course.id'}; + if (&Apache::lonnet::usertools_access($Apache::lonnet::env{'user.name'}, + $Apache::lonnet::env{'user.domain'}, + 'timezone')) { + if ($Apache::lonnet::env{'environment.timezone'} ne '') { + $timezone = $Apache::lonnet::env{'environment.timezone'}; + if ($cid ne '') { + if (($Apache::lonnet::env{'course.'.$cid.'.tzover'}) && + ($Apache::lonnet::env{'course.'.$cid.'.timezone'} ne '')) { + $timezone = $Apache::lonnet::env{'course.'.$cid.'.timezone'}; + } + } + if ($timezone ne '') { + if (DateTime::TimeZone->is_valid_name($timezone)) { + return $timezone; + } + } + } + } if ($cid ne '') { if ($Apache::lonnet::env{'course.'.$cid.'.timezone'}) { $timezone = $Apache::lonnet::env{'course.'.$cid.'.timezone'};