mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved format of ttl phrases.
This commit is contained in:
parent
47756fb8c3
commit
f4a02b126d
1 changed files with 18 additions and 9 deletions
|
@ -392,15 +392,24 @@ QString FormatPhone(const QString &phone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FormatTTL(float64 ttl) {
|
QString FormatTTL(float64 ttl) {
|
||||||
return (ttl <= 3600 * 23)
|
if (ttl < 86400) {
|
||||||
? tr::lng_hours(tr::now, lt_count, int(ttl / 3600))
|
return tr::lng_hours(tr::now, lt_count, int(ttl / 3600));
|
||||||
: (ttl <= (86400) * 6)
|
} else if (ttl < 86400 * 7) {
|
||||||
? tr::lng_days(tr::now, lt_count, int(ttl / (86400)))
|
return tr::lng_days(tr::now, lt_count, int(ttl / (86400)));
|
||||||
: (ttl <= (86400 * 7) * 3)
|
} else if (ttl < 86400 * 31) {
|
||||||
? tr::lng_weeks(tr::now, lt_count, int(ttl / (86400 * 7)))
|
const auto days = int(ttl / 86400);
|
||||||
: (ttl <= (86400 * 31) * 11)
|
if ((int(ttl) % 7) == 0) {
|
||||||
? tr::lng_months({}, lt_count, int(ttl / (86400 * 31)))
|
return tr::lng_weeks(tr::now, lt_count, int(days / 7));
|
||||||
: tr::lng_years({}, lt_count, std::round(ttl / (86400 * 365)));
|
} else {
|
||||||
|
return tr::lng_weeks(tr::now, lt_count, int(days / 7))
|
||||||
|
+ ' '
|
||||||
|
+ tr::lng_days(tr::now, lt_count, int(days % 7));
|
||||||
|
}
|
||||||
|
} else if (ttl < (86400 * 31) * 12) {
|
||||||
|
return tr::lng_months(tr::now, lt_count, int(ttl / (86400 * 31)));
|
||||||
|
} else {
|
||||||
|
return tr::lng_years({}, lt_count, std::round(ttl / (86400 * 365)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FormatTTLAfter(float64 ttl) {
|
QString FormatTTLAfter(float64 ttl) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue