[Rt-commit] rt branch, 4.4/time-durations, created. rt-4.2.10-121-gd6ce8e6

Alex Vandiver alexmv at bestpractical.com
Tue Apr 28 12:06:56 EDT 2015


The branch, 4.4/time-durations has been created
        at  d6ce8e6702900ffe49be78a39f6ddc9bf9b3ac82 (commit)

- Log -----------------------------------------------------------------
commit 3251f98e59e6b1811046b3303828b6d896ab90b3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Apr 28 11:56:33 2015 -0400

    Don't round large nubers of hours worked into days
    
    The phrase "7 days worked" may imply a concept of business hours -- that
    is, 8-hour work days, and thus "7 days" 56 hours -- whereas the days
    here are full 24-hour days.
    
    Instead, always display fractional hours, as well as minutes.

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 40911f8..1cf1856 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1376,8 +1376,12 @@ sub _DurationAsString {
     my $self = shift;
     my $value = shift;
     return "" unless $value;
-    return RT::Date->new( $self->CurrentUser )
-        ->DurationAsString( $value * 60 );
+    if ($value < 60) {
+        return $_[0]->loc("[quant,_1,minute,minutes]", $value);
+    } else {
+        my $h = sprintf("%.2f", $value / 60 );
+        return $_[0]->loc("[quant,_1,hour,hours] ([quant,_2,minute,minutes])", $h, $value);
+    }
 }
 
 =head2 TimeWorkedAsString

commit f7ddacfc2c86ecc4a925e936798a373bd6a7b830
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Apr 28 11:57:54 2015 -0400

    Use consistent number of significant figures on hour rounding

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index e55201f..edc30b3 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1185,7 +1185,7 @@ sub _FormatUser {
         elsif ($duration < 60) {
             return ("Worked [quant,_1,minute,minutes]", $duration); # loc()
         } else {
-            return ("Worked [quant,_1,hour,hours] ([quant,_2,minute,minutes])", sprintf("%.1f", $duration / 60), $duration); # loc()
+            return ("Worked [quant,_1,hour,hours] ([quant,_2,minute,minutes])", sprintf("%.2f", $duration / 60), $duration); # loc()
         }
     },
     PurgeTransaction => sub {
diff --git a/share/html/Elements/EditTimeValue b/share/html/Elements/EditTimeValue
index ac27665..8b92f84 100644
--- a/share/html/Elements/EditTimeValue
+++ b/share/html/Elements/EditTimeValue
@@ -59,7 +59,7 @@ $ValueName ||= $Name;
 $UnitName  ||= ($Name||$ValueName) . '-TimeUnits';
 
 if ($InputUnits eq 'minutes' && RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentUser'})) {
-    $Default = sprintf '%.3f', $Default / 60
+    $Default = sprintf '%.2f', $Default / 60
         unless $Default eq '';
 }
 </%INIT>
diff --git a/share/html/Ticket/Elements/ShowTime b/share/html/Ticket/Elements/ShowTime
index 2645353..9f68a1e 100644
--- a/share/html/Ticket/Elements/ShowTime
+++ b/share/html/Ticket/Elements/ShowTime
@@ -48,7 +48,7 @@
 % if ($minutes < 60) {
 <&|/l, $minutes &>[quant,_1,minute,minutes]</&>
 % } else {
-<&|/l, sprintf("%.1f",$minutes / 60), $minutes &>[quant,_1,hour,hours] ([quant,_2,minute,minutes])</&>
+<&|/l, sprintf("%.2f",$minutes / 60), $minutes &>[quant,_1,hour,hours] ([quant,_2,minute,minutes])</&>
 % }
 <%init>
 $minutes ||= 0;

commit d6ce8e6702900ffe49be78a39f6ddc9bf9b3ac82
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Apr 28 12:05:00 2015 -0400

    Roll TimeWorked and TimeEstimated up in to hours, like TimeLeft
    
    22ce1dc8 begain using TimeLeftAsString in the columnmap, but left
    TimeEstimated and TimeWorked as-is, for unclear reasons.  Use the
    ..AsString versions for all three time metrics.

diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index 24e73d4..e61b223 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -174,7 +174,7 @@ $COLUMN_MAP = {
     TimeWorked => {
         attribute => 'TimeWorked',
         title     => 'Time Worked', # loc
-        value     => sub { return $_[0]->TimeWorked }
+        value     => sub { return $_[0]->TimeWorkedAsString }
     },
     TimeLeft => {
         attribute => 'TimeLeft',
@@ -184,7 +184,7 @@ $COLUMN_MAP = {
     TimeEstimated => {
         attribute => 'TimeEstimated',
         title     => 'Time Estimated', # loc
-        value     => sub { return $_[0]->TimeEstimated }
+        value     => sub { return $_[0]->TimeEstimatedAsString }
     },
     StartsRelative => {
         title     => 'Starts', # loc

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


More information about the rt-commit mailing list