| MetaStore documentation | Contained in the MetaStore distribution. |
MetaStore::Base - base class.
use MetaStore::Base;
use base qw/MetaStore::Base/
Base class.
MetaStore, README
Zahatski Aliaksandr, <zag@cpan.org>
Copyright (C) 2006 by Zahatski Aliaksandr
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
| 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__