| 1 | package OpenInteract2::Setup::InitializeTimezone; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # $Id: InitializeTimezone.pm,v 1.2 2005/03/18 04:09:51 lachoy Exp $ | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 87 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 87 | ▶ | use base qw( OpenInteract2::Setup ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 87 | ▶ | use DateTime::TimeZone; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 87 | ▶ | use Log::Log4perl qw( get_logger ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 87 | ▶ | use OpenInteract2::Constants qw( LOG_INIT ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 87 | ▶ | use OpenInteract2::Exception qw( oi_error ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 87 | $OpenInteract2::Setup::InitializeTimezone::VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 87 | my ( $log ); | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 87 | ▶ | sub get_name { | ||||||||||||||||||
|
Subroutine
get_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 17 | 87 | return 'initialize timezone'; | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 0 | ▶ | sub execute { | ||||||||||||||||||
|
Subroutine
execute: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 21 | 0 | my ( $self, $ctx ) = @_; | |||||||||||||||||||
| 22 | 0 | ▶ | $log ||= get_logger( LOG_INIT ); | ||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.INITIALIZE")
MC/DC0%0/2
$log ||= get_logger("OI2.INITIALIZE")
$log
get_logger("OI2.INITIALIZE")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.INITIALIZE")
| |||||||||||||||||||||
| 23 | 0 | my $server_config = $ctx->server_config; | |||||||||||||||||||
| 24 | 0 | my $timezone = $server_config->{timezone}; | |||||||||||||||||||
| 25 | 0 | ▶ | unless ( $timezone ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 0 | $timezone = 'America/New_York'; | |||||||||||||||||||
| 27 | 0 | $log->warn( | |||||||||||||||||||
| 28 | "No timezone set in server configuration! Please set the ", | ||||||||||||||||||||
| 29 | "configuration key 'Global.timezone' to a valid ", | ||||||||||||||||||||
| 30 | "DateTime::TimeZone value. (I'm going to be a cultural ", | ||||||||||||||||||||
| 31 | "imperialist and assume '$timezone'.)" | ||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | 0 | my $timezone_object = DateTime::TimeZone->new( name => $timezone ); | |||||||||||||||||||
| 35 | 0 | $ctx->timezone( $timezone ); | |||||||||||||||||||
| 36 | 0 | $ctx->timezone_object( $timezone_object ); | |||||||||||||||||||
| 37 | 0 | $log->info( "Assigned timezone '$timezone' to context ok" ); | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 87 | OpenInteract2::Setup->register_factory_type( get_name() => __PACKAGE__ ); | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 87 | 1; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | __END__ | ||||||||||||||||||||