Apache2-WebApp-Plugin-DateTime

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    Return the total days between dates.

      my $date1 = 'Sun Oct 18 15:14:48 2009';     # then and
      my $date2 = localtime(time);                # now

      my $delta = $c->plugin('DateTime')->days_between_dates( $date1, $date2 );

  format_time
    Convert seconds-since-epoch to a human readable format.

      my $date = $c->plugin('DateTime')->format_time( $unix_time, '%a %b %d %T %Y' );

    See Date::Format for character conversion specification.

SEE ALSO
    Apache2::WebApp, Apache2::WebApp::Plugin, Date::Calc, Date::Format,
    Date::Manip, Params::Validate, Time::ParseDate

AUTHOR
    Marc S. Brooks, <mbrooks@cpan.org> - <http://mbrooks.info>

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

    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) ) );

    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);
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~[  PRIVATE METHODS  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#----------------------------------------------------------------------------+
# _init(\%params)
#
# Return a reference of $self to the caller.

sub _init {

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


  my $date1 = 'Sun Oct 18 15:14:48 2009';     # then and
  my $date2 = localtime(time);                # now

  my $delta = $c->plugin('DateTime')->days_between_dates( $date1, $date2 );

=head2 format_time

Convert seconds-since-epoch to a human readable format.

  my $date = $c->plugin('DateTime')->format_time( $unix_time, '%a %b %d %T %Y' );

See L<Date::Format> for character conversion specification.

=head1 SEE ALSO

L<Apache2::WebApp>, L<Apache2::WebApp::Plugin>, L<Date::Calc>, L<Date::Format>,
L<Date::Manip>, L<Params::Validate>, L<Time::ParseDate>

=head1 AUTHOR



( run in 0.669 second using v1.01-cache-2.11-cpan-39bf76dae61 )