daily pastebin goal
34%
SHARE
TWEET

Redmine Human Readable time format

lpiotrowski Feb 5th, 2015 19 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From 69609c7152b11dd218072214a2b83e434b6ca179 Mon Sep 17 00:00:00 2001
  2. From: root <root@vpslpiot.(none)>
  3. Date: Thu, 5 Feb 2015 18:15:45 +0100
  4. Subject: [PATCH] Changed time to human readable
  5.  
  6. ---
  7. app/helpers/queries_helper.rb         |    4 ++++
  8.  app/views/my/blocks/_timelog.html.erb |    6 +++---
  9.  lib/redmine/i18n.rb                   |    4 +++-
  10.  3 files changed, 10 insertions(+), 4 deletions(-)
  11.  
  12. diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
  13. index b930444..b162059 100644
  14. --- a/app/helpers/queries_helper.rb
  15. +++ b/app/helpers/queries_helper.rb
  16. @@ -103,6 +103,10 @@ module QueriesHelper
  17.        issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
  18.      when :done_ratio
  19.        progress_bar(value, :width => '80px')
  20. +    when :estimated_hours
  21. +      l_hours(value)
  22. +    when :spent_hours
  23. +      l_hours(value)
  24.      when :relations
  25.        other = value.other_issue(issue)
  26.        content_tag('span',
  27. diff --git a/app/views/my/blocks/_timelog.html.erb b/app/views/my/blocks/_timelog.html.erb
  28. index f88de95..a2e8c28 100644
  29. --- a/app/views/my/blocks/_timelog.html.erb
  30. +++ b/app/views/my/blocks/_timelog.html.erb
  31. @@ -14,7 +14,7 @@ entries_by_day = entries.group_by(&:spent_on)
  32.  <% end %>
  33.  
  34.  <div class="total-hours">
  35. -<p><%= l(:label_total_time) %>: <%= html_hours("%.2f" % entries.sum(&:hours).to_f) %></p>
  36. +<p><%= l(:label_total) %>: <%= l_hours(entries.sum(&:hours)) %></p>
  37.  </div>
  38.  
  39.  <% if entries.any? %>
  40. @@ -31,7 +31,7 @@ entries_by_day = entries.group_by(&:spent_on)
  41.      <tr class="odd">
  42.      <td><strong><%= day == Date.today ? l(:label_today).titleize : format_date(day) %></strong></td>
  43.      <td colspan="2"></td>
  44. -    <td class="hours"><em><%= html_hours("%.2f" % entries_by_day[day].sum(&:hours).to_f) %></em></td>
  45. +    <td class="hours"><em><%= l_hours(entries_by_day[day].sum(&:hours)) %></em></td>
  46.      <td></td>
  47.      </tr>
  48.      <% entries_by_day[day].each do |entry| -%>
  49. @@ -39,7 +39,7 @@ entries_by_day = entries.group_by(&:spent_on)
  50.      <td class="activity"><%=h entry.activity %></td>
  51.      <td class="subject"><%=h entry.project %> <%= h(' - ') + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td>
  52.      <td class="comments"><%=h entry.comments %></td>
  53. -    <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
  54. +    <td class="hours"><%= l_hours(entry.hours) %></td>
  55.      <td class="buttons">
  56.      <% if entry.editable_by?(@user) -%>
  57.          <%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry},
  58. diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb
  59. index 3ec6c5d..657b3f8 100644
  60. --- a/lib/redmine/i18n.rb
  61. +++ b/lib/redmine/i18n.rb
  62. @@ -45,7 +45,9 @@ module Redmine
  63.  
  64.      def l_hours(hours)
  65.        hours = hours.to_f
  66. -      l((hours < 2.0 ? :label_f_hour : :label_f_hour_plural), :value => ("%.2f" % hours.to_f))
  67. +      hours_part = hours.truncate
  68. +      minutes_part = ((hours - hours_part) * 60).round
  69. +      "#{hours_part}h #{minutes_part}m"
  70.      end
  71.  
  72.      def ll(lang, str, value=nil)
  73. --
  74. 1.7.10.4
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top