Debian Codegraph @

src/util/dtimeunitformatter.cpp

raw
1 // SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-3.0-or-later
4
5 #include "dtimeunitformatter.h"
6
7 #include <QString>
8
9 DCORE_BEGIN_NAMESPACE
10
11 DTimeUnitFormatter::DTimeUnitFormatter()
12 : DAbstractUnitFormatter()
13 {
14 }
15
16 uint DTimeUnitFormatter::unitConvertRate(int unitId) const
17 {
18 switch (unitId) {
19 case Seconds:
20 return 60;
21 case Minute:
22 return 60;
23 case Hour:
24 return 24;
25 default:;
26 }
27
28 return 0;
29 }
30
31 QString DTimeUnitFormatter::unitStr(int unitId) const
32 {
33 switch (unitId) {
34 case Seconds:
35 return QStringLiteral("s");
36 case Minute:
37 return QStringLiteral("m");
38 case Hour:
39 return QStringLiteral("h");
40 case Day:
41 return QStringLiteral("d");
42 default:;
43 }
44
45 return QString();
46 }
47
48 DCORE_END_NAMESPACE