[Rt-commit] rt branch, 4.2/time-worked-txn-display, created. rt-4.1.6-387-gac33d28

Thomas Sibley trs at bestpractical.com
Fri Mar 29 18:50:56 EDT 2013


The branch, 4.2/time-worked-txn-display has been created
        at  ac33d28fc9de11a27cf845e47b97cbed623677b6 (commit)

- Log -----------------------------------------------------------------
commit ac33d28fc9de11a27cf845e47b97cbed623677b6
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Mar 29 15:48:55 2013 -0700

    Calculate the duration of time worked for history display
    
    Showing a useful duration is easier to quickly read and understand than
    showing the before and after value in minutes.  Why subtract when the
    computer can!

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 13635ec..829ef27 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -997,6 +997,20 @@ sub _FormatUser {
                     ($self->OldValue? "'".$self->OldValue ."'" : $self->loc("(no value)")) , "'". $self->NewValue."'" );
         }
     },
+    "Set-TimeWorked" => sub {
+        my $self = shift;
+        my $old  = $self->OldValue || 0;
+        my $new  = $self->NewValue || 0;
+        my $duration = $new - $old;
+        if ($duration < 0) {
+            return ("Adjusted time worked by [quant,_1,minute,minutes]", $duration);
+        }
+        elsif ($duration < 60) {
+            return ("Worked [quant,_1,minute,minutes]", $duration);
+        } else {
+            return ("Worked [quant,_1,hour,hours] ([numf,_2] minutes)", sprintf("%.1f", $duration / 60), $duration);
+        }
+    },
     PurgeTransaction => sub {
         my $self = shift;
         return ("Transaction [_1] purged", $self->Data);    #loc

-----------------------------------------------------------------------


More information about the Rt-commit mailing list