07 Jun 2008 15:26:02 UTC
- Distribution: Time-Piece-MySQL
- Module version: 0.06
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (3)
- Testers (2706 / 31 / 0)
- KwaliteeBus factor: 0
- 84.47% Coverage
- License: unknown
- Activity24 month
- Download (3.78KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:1 non-PAUSE userKASEI Marty Pauleyand 1 contributors
- Marty Pauley
- OBJECT METHODS
- SEE ALSO
Time::Piece::MySQL - Adds MySQL-specific methods to Time::Piece
use Time::Piece::MySQL; my $time = localtime; print $time->mysql_datetime; print $time->mysql_date; print $time->mysql_time; my $time = Time::Piece->from_mysql_datetime( $mysql_datetime ); my $time = Time::Piece->from_mysql_date( $mysql_date ); my $time = Time::Piece->from_mysql_timestamp( $mysql_timestamp );
Using this module instead of, or in addition to,
Time::Pieceadds a few MySQL-specific date-time methods to
Returns the date and/or time in a format suitable for use by MySQL.
Given a date, datetime, or timestamp value as returned from MySQL, these constructors return a new Time::Piece object. If the value is NULL, they will retrun undef.
Time::Pieceitself only works with times in the Unix epoch, this module has the same limitation. However, MySQL itself handles date and datetime columns from '1000-01-01' to '9999-12-31'. Feeding in times outside of the Unix epoch to any of the constructors has unpredictable results.
Also, MySQL doesn't validate dates (because your application should); it only checks that dates are in the right format. So, your database might include dates like 2004-00-00 or 2001-02-31. Passing invalid dates to any of the constructors is a bad idea: on my system the former type (with zeros) returns undef (previous version used to die) while the latter returns a date in the following month.
Original author: Dave Rolsky <firstname.lastname@example.org>
Current maintainer: Marty Pauley <email@example.com>
(c) 2002 Dave Rolsky
(c) 2004 Marty Pauley
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Time::Piece::MySQL, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Time::Piece::MySQL
For more information on module installation, please visit the detailed CPAN module installation guide.