[Jifty-commit] r5007 - in Jifty-DBI/branches/tisql: lib/Jifty/DBI/Filter

Jifty commits jifty-commit at lists.jifty.org
Tue Feb 5 21:14:37 EST 2008


Author: ruz
Date: Tue Feb  5 21:14:36 2008
New Revision: 5007

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

Log:
 r4449 at cubic-pc (orig r4448):  sartak | 2007-11-15 23:55:10 +0300
  r45204 at onn:  sartak | 2007-11-15 15:54:39 -0500
  POD coverage
 


Modified: Jifty-DBI/branches/tisql/lib/Jifty/DBI/Filter/DateTime.pm
==============================================================================
--- Jifty-DBI/branches/tisql/lib/Jifty/DBI/Filter/DateTime.pm	(original)
+++ Jifty-DBI/branches/tisql/lib/Jifty/DBI/Filter/DateTime.pm	Tue Feb  5 21:14:36 2008
@@ -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