Show
Ignore:
Timestamp:
07/01/08 13:15:28 (6 years ago)
Author:
lamanotrama
Message:

now(time_zone => "local")

Location:
lang/perl/Parse-Syslog-Period/trunk/lib/Parse/Syslog
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Parse-Syslog-Period/trunk/lib/Parse/Syslog/Period.pm

    r14832 r14978  
    8383sub __today { 
    8484    my $self = shift; 
    85     my $from = DateTime 
    86         ->now 
    87         ->set_time_zone( 'local' ) 
    88         ->truncate( to => "day" ); 
    89  
     85    my $from = DateTime->today( time_zone => 'local' ); 
    9086    return [ $from, undef ]; 
    9187} 
     
    9490    my ( $self, $between ) = @_; 
    9591    my ( $from, $to ) = @$between; 
    96     my $now = DateTime->now->set_time_zone( 'local' ); 
     92    my $now = DateTime->now( time_zone => 'local' ); 
    9793 
    9894    $from = DateTime->new( %$from, time_zone => 'local' ) unless eval { $from->isa( 'DateTime' ) }; 
     
    108104    my ( $self, $ymdh ) = @_; 
    109105    my ( $from, $to ); 
    110     my $now = DateTime->now->set_time_zone( 'local' ); 
     106    my $now = DateTime->now( time_zone => 'local' ); 
    111107 
    112108    $from = DateTime 
     
    134130    my ( $self, $last ) = @_; 
    135131    my $from = DateTime 
    136         ->now 
    137         ->set_time_zone( 'local' ) 
     132        ->now( time_zone => 'local' ) 
    138133        ->subtract( %$last ); 
    139134 
  • lang/perl/Parse-Syslog-Period/trunk/lib/Parse/Syslog/Period/Parser.pm

    r14890 r14978  
    131131    my $logfiles = []; 
    132132    my $from = $self->from; 
    133     my $to   = $self->{delayed_to} ||= DateTime->now->set_time_zone( 'local' ); 
     133    my $to   = $self->{delayed_to} || DateTime->now( time_zone => 'local' ); 
    134134    $self->{rotate} = undef; 
    135135    $self->{patterned_file} = $self->file; 
     
    168168    my $logfiles = []; 
    169169    my $from = $self->from; 
    170     my $to   = $self->{delayed_to} ||= DateTime->now->set_time_zone( 'local' ); 
     170    my $to   = $self->{delayed_to} || DateTime->now( time_zone => 'local' ); 
    171171 
    172172    my $rotate = $self->rotate 
     
    188188    $last_rotated_date  or return [ 
    189189        {   name => $self->file, 
    190             year => DateTime->now->set_time_zone( 'local' )->year, 
     190            year => DateTime->now( time_zone => 'local' )->year, 
    191191        }, 
    192192    ]; 
     
    234234sub _dur_by_unittype { 
    235235    my ( $self, $dt1, $dt2, $type ) = @_; 
    236     return $type eq 'days'  ? $dt1->delta_days( $dt2 )->in_units( $type ) 
    237          : $type eq 'weeks' ? $dt1->delta_days( $dt2 )->in_units( $type ) 
    238          : $type eq 'months'? $dt1->delta_md( $dt2 )->in_units( $type ) 
     236    return $type eq 'days'  ? $dt1->delta_days( $dt2 )->in_units( 'days'  ) 
     237         : $type eq 'weeks' ? $dt1->delta_days( $dt2 )->in_units( 'weeks' ) 
     238         : $type eq 'months'? $dt1->delta_md(   $dt2 )->in_units( 'months' ) 
    239239         :                    croak; 
    240240}