Apache2-WebApp-Plugin-DateTime

 view release on metacpan or  search on metacpan

lib/Apache2/WebApp/Plugin/DateTime.pm  view on Meta::CPAN


#~~~~~~~~~~~~~~~~~~~~~~~~~~[  OBJECT METHODS  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#----------------------------------------------------------------------------+
# days_between_dates( $date1, $date2 )
#
# Return the total days between dates.

sub days_between_dates {
    my ( $self, $date1, $date2 )
      = validate_pos( @_,
          { type => OBJECT },
          { type => SCALAR },
          { type => SCALAR }
          );

    my $epoch1 = parsedate($date1);
    my $epoch2 = parsedate($date2);

    my @date_to   = split(/\s+/, strftime( '%Y %m %e', localtime($epoch1) ) );
    my @date_from = split(/\s+/, strftime( '%Y %m %e', localtime($epoch2) ) );

lib/Apache2/WebApp/Plugin/DateTime.pm  view on Meta::CPAN

    return Delta_Days( @date_to, @date_from );
}

#----------------------------------------------------------------------------+
# format_time( $unix_time, $format )
#
# Convert seconds-since-epoch to a human readable format.

sub format_time {
    my ( $self, $unix_time, $format )
      = validate_pos( @_,
          { type => OBJECT },
          { type => SCALAR },
          { type => SCALAR }
          );

    require Date::Format;     # since POSIX imports similiar methods

    return Date::Format::time2str($format, $unix_time, undef);
}



( run in 0.249 second using v1.01-cache-2.11-cpan-4d50c553e7e )