Subject: | Support "new" MySQL TIMESTAMP columns |
I sent this in August last year, but it appears it got lost in transmission or some such.
This is needed to support the "new" TIMESTAMP columns.
- ask
--- lib/Time/Piece/MySQL.pm~ 2004-07-21 07:42:40.000000000 -0700
+++ lib/Time/Piece/MySQL.pm 2005-08-22 02:35:41.000000000 -0700
@@ -69,6 +69,8 @@
# From MySQL version 4.1, timestamps are returned as datetime strings
my ($class, $timestamp) = @_;
my $length = length $timestamp;
+ return from_mysql_datetime(@_) if $length == 19;
+
# most timestamps have 2-digit years, except 8 and 14 char ones
if ( $length != 14 && $length != 8 ) {
$timestamp = (substr($timestamp, 0, 2) < 70 ? "20" : "19")
--- t/timestamp.t~ 2003-11-28 05:44:42.000000000 -0800
+++ t/timestamp.t 2005-08-22 02:35:56.000000000 -0700
@@ -11,6 +11,7 @@
'1202110545' => '20120211054500',
'120211054537' => '20120211054537',
'20120211054537' => '20120211054537',
+ '2005-08-10 23:20:48' => '20050810232048',
);
#my @null = qw/ 19691231235959 20380101000000 /;