KCoreAddons
kformatprivate.cpp
44 if (static_cast<int>(prefix) < static_cast<int>(KFormat::UnitPrefix::Yocto) || static_cast<int>(prefix) > static_cast<int>(KFormat::UnitPrefix::Yotta)) {
109 {KFormat::UnitPrefix::Kilo, 1e3, bpow(10), tr("k", "SI prefix for 10^3"), tr("Ki", "IEC binary prefix for 2^10")},
110 {KFormat::UnitPrefix::Mega, 1e6, bpow(20), tr("M", "SI prefix for 10^6"), tr("Mi", "IEC binary prefix for 2^20")},
111 {KFormat::UnitPrefix::Giga, 1e9, bpow(30), tr("G", "SI prefix for 10^9"), tr("Gi", "IEC binary prefix for 2^30")},
112 {KFormat::UnitPrefix::Tera, 1e12, bpow(40), tr("T", "SI prefix for 10^12"), tr("Ti", "IEC binary prefix for 2^40")},
113 {KFormat::UnitPrefix::Peta, 1e15, bpow(50), tr("P", "SI prefix for 10^15"), tr("Pi", "IEC binary prefix for 2^50")},
114 {KFormat::UnitPrefix::Exa, 1e18, bpow(60), tr("E", "SI prefix for 10^18"), tr("Ei", "IEC binary prefix for 2^60")},
115 {KFormat::UnitPrefix::Zetta, 1e21, bpow(70), tr("Z", "SI prefix for 10^21"), tr("Zi", "IEC binary prefix for 2^70")},
116 {KFormat::UnitPrefix::Yotta, 1e24, bpow(80), tr("Y", "SI prefix for 10^24"), tr("Yi", "IEC binary prefix for 2^80")},
165 QString KFormatPrivate::formatByteSize(double size, int precision, KFormat::BinaryUnitDialect dialect, KFormat::BinarySizeUnits units) const
312 QString KFormatPrivate::formatDuration(quint64 msecs, KFormat::DurationFormatOptions options) const
331 if ((options & KFormat::FoldHours) == KFormat::FoldHours && (options & KFormat::ShowMilliseconds) == KFormat::ShowMilliseconds) {
333 return tr("%1m%2.%3s").arg(hours * 60 + minutes, 1, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0')).arg(ms, 3, 10, QLatin1Char('0'));
336 return tr("%1m%2s").arg(hours * 60 + minutes, 1, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0'));
349 return tr("%1h%2m%3s").arg(hours, 1, 10, QLatin1Char('0')).arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0'));
353 if ((options & KFormat::FoldHours) == KFormat::FoldHours && (options & KFormat::ShowMilliseconds) == KFormat::ShowMilliseconds) {
355 return tr("%1:%2.%3").arg(hours * 60 + minutes, 1, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0')).arg(ms, 3, 10, QLatin1Char('0'));
358 return tr("%1:%2").arg(hours * 60 + minutes, 1, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0'));
371 return tr("%1:%2:%3").arg(hours, 1, 10, QLatin1Char('0')).arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0'));
389 return tr("%1 minutes").arg(m_locale.toString(msecs / (MSecsInMinute * 1.0), 'f', decimalPlaces));
392 return tr("%1 seconds").arg(m_locale.toString(msecs / (MSecsInSecond * 1.0), 'f', decimalPlaces));
454 If this does not fit the grammar of your language please contact the i18n team to solve the problem */
455 return tr("%1 and %2").arg(formatSingleDuration(Days, days), formatSingleDuration(Hours, hours));
460 If this does not fit the grammar of your language please contact the i18n team to solve the problem */
461 return tr("%1 and %2").arg(formatSingleDuration(Hours, hours), formatSingleDuration(Minutes, minutes));
466 If this does not fit the grammar of your language please contact the i18n team to solve the problem */
467 return tr("%1 and %2").arg(formatSingleDuration(Minutes, minutes), formatSingleDuration(Seconds, seconds));
478 return tr("Invalid date", "used when a relative date string can't be generated because the date is invalid");
501 QString KFormatPrivate::formatRelativeDateTime(const QDateTime &dateTime, QLocale::FormatType format) const
520 If this does not fit the grammar of your language please contact the i18n team to solve the problem */
521 return tr("%1, %2").arg(formatRelativeDate(dateTime.date(), format), m_locale.toString(dateTime.time(), format));
Yi/Y/Y 2^80/10^24.
qint64 daysTo(const QDate &d) const const
QString toUpper() const const
BinarySizeUnits
These binary units are used in KDE by the formatByteSize() function.
Definition: kformat.h:84
Mi/M/M 2^20/10^06.
FormatType
Auto-choose a unit such that the result is in the range [0, 1000 or 1024)
qint64 daysTo(const QDateTime &other) const const
QTime time() const const
–/-/µ 10^-6
Ei/E/E 2^60/10^18.
Pi/P/P 2^50/10^15.
Fold the hours into the minutes, e.g. 83:45 or 83m45s, overrides HideSeconds.
Definition: kformat.h:188
–/-/y 10^-24
Zi/Z/Z 2^70/10^21.
Hide the seconds, e.g. 1:23 or 1h23m, overrides ShowMilliseconds.
Definition: kformat.h:187
–/-/z 10^-21
–/-/n 10^-9
–/-/a 10^-18
Ki/K/k 1024/1000.
bool isValid() const const
Ti/T/T 2^40/10^12.
"bit"
QDateTime currentDateTime()
QDate date() const const
qint64 secsTo(const QDateTime &other) const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QDate currentDate()
–/-/m 10^-3
–/-/p 10^-12
–/-/f 10^-15
Gi/G/G 2^30/10^09.
Auto-choose a unit such that the result is in the range [0, 1000 or 1024)
Definition: kformat.h:86
QFuture< void > map(Sequence &sequence, MapFunctor function)
Include milliseconds in format, e.g. 1:23:45.678.
Definition: kformat.h:186
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 18 2021 23:02:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 18 2021 23:02:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.