Server IP : 103.119.228.120 / Your IP : 18.191.178.16 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/local/share/perl5/DateTime/TimeZone/OlsonDB/ |
Upload File : |
package DateTime::TimeZone::OlsonDB::Zone; $DateTime::TimeZone::OlsonDB::Zone::VERSION = '2.01'; use strict; use warnings; use DateTime::TimeZone; use DateTime::TimeZone::OlsonDB; use DateTime::TimeZone::OlsonDB::Change; use DateTime::TimeZone::OlsonDB::Observance; use List::Util qw( first max ); use Params::Validate qw( validate SCALAR ARRAYREF ); sub new { my $class = shift; my %p = validate( @_, { name => { type => SCALAR }, observances => { type => ARRAYREF }, olson_db => 1, } ); my $self = { name => $p{name}, observances => $p{observances}, changes => [], infinite_rules => {}, }; return bless $self, $class; } sub name { $_[0]->{name} } sub last_rules_year { my $self = shift; my $odb = shift; my $last_rule = $self->{observances}[-1]{rules}; return unless $last_rule; my @rules = $odb->rules_by_name($last_rule); return $rules[-1]->min_year(); } sub expand_observances { my $self = shift; my $odb = shift; my $max_year = shift; my $prev_until; ## no critic (ControlStructures::ProhibitCStyleForLoops) for ( my $x = 0; $x < @{ $self->{observances} }; $x++ ) { my %p = %{ $self->{observances}[$x] }; my $rules_name = delete $p{rules}; my $last_offset_from_std = $self->last_change ? $self->last_change->offset_from_std : 0; my $last_offset_from_utc = $self->last_change ? $self->last_change->offset_from_utc : 0; my $obs = DateTime::TimeZone::OlsonDB::Observance->new( %p, utc_start_datetime => $prev_until, rules => [ $odb->rules_by_name($rules_name) ], last_offset_from_utc => $last_offset_from_utc, last_offset_from_std => $last_offset_from_std, ); my $rule = $obs->first_rule; my $letter = $rule ? $rule->letter : q{}; my $change = DateTime::TimeZone::OlsonDB::Change->new( type => 'observance', utc_start_datetime => $obs->utc_start_datetime, local_start_datetime => $obs->local_start_datetime, short_name => $obs->formatted_short_name($letter), observance => $obs, $rule ? ( rule => $rule ) : (), ); if ($DateTime::TimeZone::OlsonDB::DEBUG) { ## no critic (InputOutput::RequireCheckedSyscalls) print "Adding observance change ...\n"; $change->_debug_output; } $self->add_change($change); if ( $obs->rules ) { $obs->expand_from_rules( $self, $max_year ); } $prev_until = $obs->until( $self->last_change ? $self->last_change->offset_from_std : 0 ); # last observance if ( $x == $#{ $self->{observances} } ) { foreach my $rule ( $obs->rules ) { if ( $rule->is_infinite ) { $self->add_infinite_rule($rule); } } } } } sub add_change { my $self = shift; my $change = shift; if ( defined $change->utc_start_datetime ) { if ( @{ $self->{changes} } && $self->{changes}[-1]->utc_start_datetime && $self->{changes}[-1]->utc_start_datetime == $change->utc_start_datetime ) { if ( $self->{changes}[-1]->rule && $change->observance ) { ## no critic (InputOutput::RequireCheckedSyscalls) print " Ignoring previous rule change, that starts the same time as current observance change\n\n" if $DateTime::TimeZone::OlsonDB::DEBUG; $self->{changes}[-1] = $change; return; } die "Cannot add two different changes that have the same UTC start datetime!\n"; } my $last_change = $self->last_change; if ( $last_change->short_name eq $change->short_name && $last_change->total_offset == $change->total_offset && $last_change->is_dst == $change->is_dst && $last_change->observance eq $change->observance ) { my $last_rule = $last_change->rule || q{}; my $new_rule = $change->rule || q{}; if ( $last_rule eq $new_rule ) { ## no critic (InputOutput::RequireCheckedSyscalls) print "Skipping identical change\n" if $DateTime::TimeZone::OlsonDB::DEBUG; return; } } push @{ $self->{changes} }, $change; } else { if ( $self->{earliest} ) { die 'There can only be one earliest time zone change!'; } else { $self->{earliest} = $change; } } } sub add_infinite_rule { $_[0]->{infinite_rules}{ $_[1] } = $_[1]; } sub last_change { return unless @{ $_[0]->{changes} } || $_[0]->{earliest}; return ( @{ $_[0]->{changes} } ? $_[0]->{changes}[-1] : $_[0]->{earliest} ); } sub sorted_changes { ( ( defined $_[0]->{earliest} ? $_[0]->{earliest} : () ), sort { $a->utc_start_datetime <=> $b->utc_start_datetime } @{ $_[0]->{changes} } ); } sub infinite_rules { values %{ $_[0]->{infinite_rules} } } 1;