File indexing completed on 2022-11-29 20:26:08

0001 /**
0002  * SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #include "formatter.h"
0008 
0009 #include <QDateTime>
0010 
0011 QString Formatter::formatDuration(int seconds)
0012 {
0013     const int minutes = seconds / 60;
0014     const int hours = minutes / 60;
0015     const int minutesRemainder = minutes % 60;
0016 
0017     const QString minutesString = minutesRemainder > 9 ? QString::number(minutesRemainder) : QStringLiteral("0") + QString::number(minutesRemainder);
0018 
0019     return QString::number(hours) + QStringLiteral(":") + minutesString;
0020 }
0021 
0022 QString Formatter::formatTime(const QDateTime &time)
0023 {
0024     return time.toString(QStringLiteral("hh:mm"));
0025 }