[Rt-commit] r18571 - in rt/3.999/trunk: . lib/RT
sartak at bestpractical.com
sartak at bestpractical.com
Tue Feb 24 21:09:49 EST 2009
Author: sartak
Date: Tue Feb 24 21:09:49 2009
New Revision: 18571
Added:
rt/3.999/trunk/lib/RT/DateTime/
rt/3.999/trunk/lib/RT/DateTime/Duration.pm
Modified:
rt/3.999/trunk/ (props changed)
rt/3.999/trunk/lib/RT/DateTime.pm
Log:
r80535 at onn: sartak | 2009-02-24 21:09:33 -0500
Add a basic RT::DateTime::Duration
Modified: rt/3.999/trunk/lib/RT/DateTime.pm
==============================================================================
--- rt/3.999/trunk/lib/RT/DateTime.pm (original)
+++ rt/3.999/trunk/lib/RT/DateTime.pm Tue Feb 24 21:09:49 2009
@@ -4,6 +4,8 @@
package RT::DateTime;
use base 'Jifty::DateTime';
+use RT::DateTime::Duration;
+
sub age {
my $self = shift;
my $until = shift || RT::DateTime->now;
Added: rt/3.999/trunk/lib/RT/DateTime/Duration.pm
==============================================================================
--- (empty file)
+++ rt/3.999/trunk/lib/RT/DateTime/Duration.pm Tue Feb 24 21:09:49 2009
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+package RT::DateTime::Duration;
+use base 'DateTime::Duration';
+
+use overload (
+ q{""} => '_stringify',
+);
+
+sub _stringify {
+ my $self = shift;
+ my ($days, $hours, $minutes) = $self->in_units('days', 'hours', 'minutes');
+
+ # Obviously not good enough, but a start.
+ return "$days days, $hours hours, $minutes minutes";
+}
+
+1;
+
More information about the Rt-commit
mailing list