Project

General

Profile

Patch #14740 » RM_14740_display_hours_decimals_only_if_fractional_V2.diff

new patch - Jérôme BATAILLE, 2014-06-13 19:09

View differences:

i18n.rb (revision 1907)
28 28
    
29 29
    def l_hours(hours)
30 30
      hours = hours.to_f
31
      l((hours < 2.0 ? :label_f_hour : :label_f_hour_plural), :value => ("%.2f" % hours.to_f))
31
      # Specific : do not display decimals if zero
32
      hours_rounded = hours.round(2)
33
      hours_i = hours_rounded.to_i
34
      if hours_rounded != hours_i
35
        hours_s = ("%.2f" % hours.to_f)
36
      else
37
        hours_s = hours_i
38
      end
39
      # END -- Specific : do not display decimals if zero
40

  
41
      l(((hours > -2.0 && hours < 2.0) ? :label_f_hour : :label_f_hour_plural), :value => hours_s)
32 42
    end
33 43
    
34 44
    def ll(lang, str, value=nil)
(3-3/4)