[Jifty-commit] r4448 - in Jifty-DBI/trunk: lib/Jifty/DBI/Filter

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Nov 15 15:55:11 EST 2007


Author: sartak
Date: Thu Nov 15 15:55:10 2007
New Revision: 4448

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm

Log:
 r45204 at onn:  sartak | 2007-11-15 15:54:39 -0500
 POD coverage


Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm	Thu Nov 15 15:55:10 2007
@@ -13,15 +13,6 @@
 use constant _strptime  => '%Y-%m-%d %H:%M:%S';
 use constant _parser    => DateTime::Format::ISO8601->new();
 
-__PACKAGE__->mk_classdata("_formatter");
-sub formatter {
-    my $self = shift;
-    unless ($self->_formatter) {
-         $self->_formatter(DateTime::Format::Strptime->new(pattern => $self->_strptime));
-    }
-    return $self->_formatter;
-}
-
 =head1 NAME
 
 Jifty::DBI::Filter::DateTime - DateTime object wrapper around date columns
@@ -35,6 +26,27 @@
 Both input and output will always be coerced into UTC (or, in the case of
 Dates, the Floating timezone) for consistency.
 
+=head2 formatter
+
+This is an instance of the DateTime::Format object used for inflating the
+string in the database to a DateTime object. By default it is a
+L<DateTime::Format::Strptime> object that uses the C<_strptime> method as its
+pattern.
+
+You can use the _formatter classdata storage as a cache so you don't need
+to re-instantiate your format object every C<decode>.
+
+=cut
+
+__PACKAGE__->mk_classdata("_formatter");
+sub formatter {
+    my $self = shift;
+    unless ($self->_formatter) {
+         $self->_formatter(DateTime::Format::Strptime->new(pattern => $self->_strptime));
+    }
+    return $self->_formatter;
+}
+
 =head2 encode
 
 If value is DateTime object then converts it into ISO format


More information about the Jifty-commit mailing list