[Bps-public-commit] r17536 - in Net-Trac/trunk: .

trs at bestpractical.com trs at bestpractical.com
Fri Jan 2 16:32:06 EST 2009


Author: trs
Date: Fri Jan  2 16:32:06 2009
New Revision: 17536

Modified:
   Net-Trac/trunk/   (props changed)
   Net-Trac/trunk/lib/Net/Trac/Ticket.pm

Log:
 r43412 at zot:  tom | 2009-01-02 16:31:52 -0500
 Convenience methods to turn the time and changetime props into DTs


Modified: Net-Trac/trunk/lib/Net/Trac/Ticket.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/Ticket.pm	(original)
+++ Net-Trac/trunk/lib/Net/Trac/Ticket.pm	Fri Jan  2 16:32:06 2009
@@ -2,6 +2,7 @@
 use Moose;
 use Params::Validate qw(:all);
 use Lingua::EN::Inflect qw();
+use DateTime::Format::ISO8601;
 
 use Net::Trac::TicketSearch;
 use Net::Trac::TicketHistory;
@@ -45,6 +46,16 @@
     *{ "Net::Trac::Ticket::" . $prop } = sub { shift->state->{$prop} };
 }
 
+sub created       { shift->_time_to_datetime('time') }
+sub last_modified { shift->_time_to_datetime('changetime') }
+
+sub _time_to_datetime {
+    my ($self, $prop) = @_;
+    my $time = $self->$prop;
+    $time =~ s/ /T/;
+    return DateTime::Format::ISO8601->parse_datetime( $time );
+}
+
 sub BUILD {
     my $self = shift;
     $self->_fetch_new_ticket_metadata;
@@ -335,8 +346,6 @@
     return wantarray ? @{$self->_attachments} : $self->_attachments;
 }
 
-#http://barnowl.mit.edu/ticket/36?format=tab
-
 __PACKAGE__->meta->make_immutable;
 no Moose;
 



More information about the Bps-public-commit mailing list