Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wxutils.cpp
Go to the documentation of this file.
1 
8 /* This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This software is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this software. If not, see
20 * <http://www.gnu.org/licenses/>.
21 *
22 */
23 
24 #include "wxutils.h"
25 #include <wx/translation.h>
26 
27 WXIMPEX wxString GetFormattedTimeSpan(const wxTimeSpan& timeSpan)
28 {
29  if (timeSpan.IsNull())
30  {
31  return wxEmptyString;
32  };
33  if (timeSpan.GetHours() >= 1)
34  {
35  // longer than 1 h, format hours:minutes
36  return timeSpan.Format(_("%H:%M h"));
37  }
38  else
39  {
40  // shorter than 1 h
41  if (timeSpan.GetSeconds() > 60)
42  {
43  // format minutes:seconds
44  return timeSpan.Format(_("%M:%S min"));
45  }
46  else
47  {
48  if (timeSpan.GetSeconds() < 1)
49  {
50  // shorter then 1 s, don't display anything
51  return wxEmptyString;
52  }
53  else
54  {
55  // below 1 min, show only seconds
56  return timeSpan.Format(_("%S s"));
57  }
58  }
59  }
60 }
WXIMPEX wxString GetFormattedTimeSpan(const wxTimeSpan &timeSpan)
Definition: wxutils.cpp:27
#define WXIMPEX
Definition: hugin_shared.h:40