MetaStore::Base - base class.


MetaStore documentation Contained in the MetaStore distribution.

Index


Code Index:

NAME

Top

MetaStore::Base - base class.

SYNOPSIS

Top

    use MetaStore::Base;
    use base qw/MetaStore::Base/

DESCRIPTION

Top

Base class.

METHODS

Top

SEE ALSO

Top

MetaStore, README

AUTHOR

Top

Zahatski Aliaksandr, <zag@cpan.org>

COPYRIGHT AND LICENSE

Top


MetaStore documentation Contained in the MetaStore distribution.
package MetaStore::Base;


use Data::Dumper;
use Time::Local;
use Template;
use Template::Plugin::Date;
use WebDAO::Base;
use strict;
use warnings;
use base qw/WebDAO::Base/;
our $VERSION = '0.01';

sub _init {
    my $self = shift;
    return $self->init(@_);
}

sub init{ 1 };

sub time2mysql {
    my ( $self, $time ) = @_;
    $time = time() unless defined($time);
    my ( $sec, $min, $hour, $day, $month, $year ) = ( localtime($time) )[ 0, 1, 2, 3, 4, 5 ];
    $year  += 1900;
    $month += 1;
    $time = sprintf( '%.4d-%.2d-%.2d %.2d:%.2d:%.2d', $year, $month, $day, $hour, $min, $sec );
    return $time;
}

sub mysql2time {
    my ( $self, $time ) = @_;
    return time() unless $time;
    my ( $year, $month, $day, $hour, $min, $sec ) = $time =~ m/(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/;
    return '0' unless ( $year + $month + $day + $hour + $min + $sec );
    $year  -= 1900;
    $month -= 1;
    $time = timelocal( $sec, $min, $hour, $day, $month, $year );
    return $time;
}

1;
__END__