diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-06-04 11:13:38 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-06-04 11:13:38 +0100 |
| commit | ab1c8a67afba072b1c29f0c3c34aa9779643e66a (patch) | |
| tree | 605b85098b25c61741694de6da8aab3b186d3cce /src/lib/util.cc | |
| parent | b551048b6562c0697f8b748a2f0907dbd3d8fb96 (diff) | |
| parent | d2ee8239585be648ac63e560cb9cd363352ff11c (diff) | |
Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc index 3eb5ee30e..7da5f9f90 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -157,18 +157,27 @@ seconds_to_approximate_hms (int s) string ap; - bool const hours = h > 0; - bool const minutes = h < 6 && m > 0; - bool const seconds = h == 0 && m < 10 && s > 0; + bool hours = h > 0; + bool minutes = h < 6 && m > 0; + bool seconds = h == 0 && m < 10 && s > 0; - if (hours) { - if (m > 30 && !minutes) { - /// TRANSLATORS: h here is an abbreviation for hours - ap += locale_convert<string>(h + 1) + _("h"); - } else { - /// TRANSLATORS: h here is an abbreviation for hours - ap += locale_convert<string>(h) + _("h"); + if (m > 30 && !minutes) { + /* round up the hours */ + ++h; + } + if (s > 30 && !seconds) { + /* round up the minutes */ + ++m; + if (m == 60) { + m = 0; + minutes = false; + ++h; } + } + + if (hours) { + /// TRANSLATORS: h here is an abbreviation for hours + ap += locale_convert<string>(h) + _("h"); if (minutes || seconds) { ap += N_(" "); @@ -176,14 +185,8 @@ seconds_to_approximate_hms (int s) } if (minutes) { - /* Minutes */ - if (s > 30 && !seconds) { - /// TRANSLATORS: m here is an abbreviation for minutes - ap += locale_convert<string>(m + 1) + _("m"); - } else { - /// TRANSLATORS: m here is an abbreviation for minutes - ap += locale_convert<string>(m) + _("m"); - } + /// TRANSLATORS: m here is an abbreviation for minutes + ap += locale_convert<string>(m) + _("m"); if (seconds) { ap += N_(" "); |
