Improved format of ttl phrases.

This commit is contained in:
23rd 2023-04-21 01:21:08 +03:00
parent 47756fb8c3
commit f4a02b126d

View file

@ -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) {