<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote cite="mid:E1Im6oG-0005lQ-1C@jules.scsys.co.uk" type="cite">
<pre wrap="">Date: Sat, 27 Oct 2007 13:04:33 +0100
From: Ash Berlin <a class="moz-txt-link-rfc2396E" href="mailto:ash_cpan@firemirror.com"><ash_cpan@firemirror.com></a>
Subject: Re: [Dbix-class] inflate_column with DateTime::Format::MySQL
        and        invalid dates
To: DBIx::Class user and developer list <a class="moz-txt-link-rfc2396E" href="mailto:dbix-class@lists.scsys.co.uk"><dbix-class@lists.scsys.co.uk></a>
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:47232951.8030803@firemirror.com"><47232951.8030803@firemirror.com></a>
Content-Type: text/plain; charset=ISO-8859-1
Randy Moore wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,
I've just started using inflate_column to inflate a date in a MySQL
table into a DateTime object. It works well, as long as the the date is
valid in the database. But, I've got a case where my date is
'0000-00-00 00:00:00' until the object gets verified.
__PACKAGE__->inflate_column('verification_date', {
inflate => sub { DateTime::Format::MySQL->parse_datetime(shift); },
deflate => sub { DateTime::Format::MySQL->format_datetime(shift); },
});
</pre>
</blockquote>
<pre wrap=""><!---->
See DBIx::Class::InflateColumn::DateTime
I'm guessing you got the from somewhere in the docs? Please let me know
where so that I can update it to show differently.
</pre>
</blockquote>
Hi Ash,<br>
<br>
I was working from the docs at:<br>
<a class="moz-txt-link-freetext" href="http://search.cpan.org/~ash/DBIx-Class-0.08007/lib/DBIx/Class/InflateColumn.pm">http://search.cpan.org/~ash/DBIx-Class-0.08007/lib/DBIx/Class/InflateColumn.pm</a><br>
<br>
I also saw DBIx::Class::InflateColumn::DateTime, but the docs were
thinner on this package. So as a beginner I could get a better idea of
how the old way was going to work.<br>
<blockquote cite="mid:E1Im6oG-0005lQ-1C@jules.scsys.co.uk" type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">If I try to display the date column in a template (TT, example [%
object.verification_date.dmy('/') %] ) before the date has been set to
something valid, the DateTime::Format::MySQL code heaves its guts all
over the place (to be technical about it).
I can work around this by using:
[% IF object.get_column('verification_date') > 0 %][%
object.verification_date.dmy('/') %][% END %]
But that doesn't seem very elegant.
Can anyone suggest a cleaner solution?
Thanks much
</pre>
</blockquote>
<pre wrap=""><!---->
I'm not sure if InflateColumn::DateTime will handle this better or not,
but its the first thing to try.
Ash
</pre>
</blockquote>
Thanks for the help.<br>
<br>
<pre class="moz-signature" cols="72">--
Randy Moore
Axion Information Technologies, Inc.
phone: 301-587-3300 x 511
fax: 301-585-7450
<a class="moz-txt-link-freetext" href="http://www.axion-it.com">http://www.axion-it.com</a>
</pre>
</body>
</html>