Display dates with the system date format
This commit is contained in:
parent
041c922451
commit
c9e24c2283
|
@ -82,7 +82,7 @@ Authorizations::Entry ParseEntry(const MTPDauthorization &data) {
|
||||||
&& lastDate.weekNumber() == nowDate.weekNumber()) {
|
&& lastDate.weekNumber() == nowDate.weekNumber()) {
|
||||||
result.active = langDayOfWeek(lastDate);
|
result.active = langDayOfWeek(lastDate);
|
||||||
} else {
|
} else {
|
||||||
result.active = lastDate.toString(qsl("d.MM.yy"));
|
result.active = lastDate.toString(cDateFormat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,6 +260,7 @@ void Application::run() {
|
||||||
|
|
||||||
DEBUG_LOG(("Application Info: inited..."));
|
DEBUG_LOG(("Application Info: inited..."));
|
||||||
|
|
||||||
|
cChangeDateFormat(QLocale::system().dateFormat(QLocale::ShortFormat));
|
||||||
cChangeTimeFormat(QLocale::system().timeFormat(QLocale::ShortFormat));
|
cChangeTimeFormat(QLocale::system().timeFormat(QLocale::ShortFormat));
|
||||||
|
|
||||||
DEBUG_LOG(("Application Info: starting app..."));
|
DEBUG_LOG(("Application Info: starting app..."));
|
||||||
|
|
|
@ -1078,7 +1078,7 @@ std::optional<QString> RestrictionError(
|
||||||
auto restrictedUntil = channel->restrictedUntil();
|
auto restrictedUntil = channel->restrictedUntil();
|
||||||
if (restrictedUntil > 0 && !ChannelData::IsRestrictedForever(restrictedUntil)) {
|
if (restrictedUntil > 0 && !ChannelData::IsRestrictedForever(restrictedUntil)) {
|
||||||
auto restrictedUntilDateTime = base::unixtime::parse(channel->restrictedUntil());
|
auto restrictedUntilDateTime = base::unixtime::parse(channel->restrictedUntil());
|
||||||
auto date = restrictedUntilDateTime.toString(qsl("dd.MM.yy"));
|
auto date = restrictedUntilDateTime.toString(cDateFormat());
|
||||||
auto time = restrictedUntilDateTime.toString(cTimeFormat());
|
auto time = restrictedUntilDateTime.toString(cTimeFormat());
|
||||||
|
|
||||||
switch (restriction) {
|
switch (restriction) {
|
||||||
|
|
|
@ -386,7 +386,7 @@ QString OnlineText(TimeId online, TimeId now) {
|
||||||
const auto onlineTime = onlineFull.time().toString(cTimeFormat());
|
const auto onlineTime = onlineFull.time().toString(cTimeFormat());
|
||||||
return tr::lng_status_lastseen_yesterday(tr::now, lt_time, onlineTime);
|
return tr::lng_status_lastseen_yesterday(tr::now, lt_time, onlineTime);
|
||||||
}
|
}
|
||||||
const auto date = onlineFull.date().toString(qsl("dd.MM.yy"));
|
const auto date = onlineFull.date().toString(cDateFormat());
|
||||||
return tr::lng_status_lastseen_date(tr::now, lt_date, date);
|
return tr::lng_status_lastseen_date(tr::now, lt_date, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ QString OnlineTextFull(not_null<UserData*> user, TimeId now) {
|
||||||
const auto onlineTime = onlineFull.time().toString(cTimeFormat());
|
const auto onlineTime = onlineFull.time().toString(cTimeFormat());
|
||||||
return tr::lng_status_lastseen_yesterday(tr::now, lt_time, onlineTime);
|
return tr::lng_status_lastseen_yesterday(tr::now, lt_time, onlineTime);
|
||||||
}
|
}
|
||||||
const auto date = onlineFull.date().toString(qsl("dd.MM.yy"));
|
const auto date = onlineFull.date().toString(cDateFormat());
|
||||||
const auto time = onlineFull.time().toString(cTimeFormat());
|
const auto time = onlineFull.time().toString(cTimeFormat());
|
||||||
return tr::lng_status_lastseen_date_time(tr::now, lt_date, date, lt_time, time);
|
return tr::lng_status_lastseen_date_time(tr::now, lt_date, date, lt_time, time);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ void PaintRowDate(Painter &p, QDateTime date, QRect &rectForName, bool active, b
|
||||||
&& lastDate.weekNumber() == nowDate.weekNumber()) {
|
&& lastDate.weekNumber() == nowDate.weekNumber()) {
|
||||||
return langDayOfWeek(lastDate);
|
return langDayOfWeek(lastDate);
|
||||||
} else {
|
} else {
|
||||||
return lastDate.toString(qsl("d.MM.yy"));
|
return lastDate.toString(cDateFormat());
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
PaintRowTopRight(p, dt, rectForName, active, selected);
|
PaintRowTopRight(p, dt, rectForName, active, selected);
|
||||||
|
|
|
@ -2092,7 +2092,9 @@ TextForMimeData HistoryInner::getSelectedText() const {
|
||||||
return TextForMimeData();
|
return TextForMimeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto timeFormat = qsl(", [dd.MM.yy hh:mm]\n");
|
const auto timeFormat = QString(", [%1 %2]\n")
|
||||||
|
.arg(cDateFormat())
|
||||||
|
.arg(cTimeFormat());
|
||||||
auto groups = base::flat_set<not_null<const Data::Group*>>();
|
auto groups = base::flat_set<not_null<const Data::Group*>>();
|
||||||
auto fullSize = 0;
|
auto fullSize = 0;
|
||||||
auto texts = base::flat_map<Data::MessagePosition, TextForMimeData>();
|
auto texts = base::flat_map<Data::MessagePosition, TextForMimeData>();
|
||||||
|
|
|
@ -1765,7 +1765,9 @@ TextForMimeData ListWidget::getSelectedText() const {
|
||||||
return _selectedText;
|
return _selectedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto timeFormat = qsl(", [dd.MM.yy hh:mm]\n");
|
const auto timeFormat = QString(", [%1 %2]\n")
|
||||||
|
.arg(cDateFormat())
|
||||||
|
.arg(cTimeFormat());
|
||||||
auto groups = base::flat_set<not_null<const Data::Group*>>();
|
auto groups = base::flat_set<not_null<const Data::Group*>>();
|
||||||
auto fullSize = 0;
|
auto fullSize = 0;
|
||||||
auto texts = std::vector<std::pair<
|
auto texts = std::vector<std::pair<
|
||||||
|
|
|
@ -2708,7 +2708,7 @@ void Message::initTime() const {
|
||||||
if (forwarded && forwarded->imported) {
|
if (forwarded && forwarded->imported) {
|
||||||
const auto date = base::unixtime::parse(forwarded->originalDate);
|
const auto date = base::unixtime::parse(forwarded->originalDate);
|
||||||
item->_timeText = date.toString(
|
item->_timeText = date.toString(
|
||||||
u"d.MM.yy, "_q + cTimeFormat() + ' '
|
cDateFormat() + u", "_q + cTimeFormat() + ' '
|
||||||
) + tr::lng_imported(tr::now);
|
) + tr::lng_imported(tr::now);
|
||||||
} else {
|
} else {
|
||||||
item->_timeText = dateTime().toString(cTimeFormat());
|
item->_timeText = dateTime().toString(cTimeFormat());
|
||||||
|
|
|
@ -810,7 +810,7 @@ void OverlayWidget::updateControls() {
|
||||||
}
|
}
|
||||||
return dNow;
|
return dNow;
|
||||||
}();
|
}();
|
||||||
_dateText = Ui::FormatDateTime(d, cTimeFormat());
|
_dateText = Ui::FormatDateTime(d, cDateFormat(), cTimeFormat());
|
||||||
if (!_fromName.isEmpty()) {
|
if (!_fromName.isEmpty()) {
|
||||||
_fromNameLabel.setText(st::mediaviewTextStyle, _fromName, Ui::NameTextOptions());
|
_fromNameLabel.setText(st::mediaviewTextStyle, _fromName, Ui::NameTextOptions());
|
||||||
_nameNav = QRect(st::mediaviewTextLeft, height() - st::mediaviewTextTop, qMin(_fromNameLabel.maxWidth(), width() / 3), st::mediaviewFont->height);
|
_nameNav = QRect(st::mediaviewTextLeft, height() - st::mediaviewTextTop, qMin(_fromNameLabel.maxWidth(), width() / 3), st::mediaviewFont->height);
|
||||||
|
|
|
@ -47,6 +47,7 @@ QByteArray gLocalSalt;
|
||||||
int gScreenScale = style::kScaleAuto;
|
int gScreenScale = style::kScaleAuto;
|
||||||
int gConfigScale = style::kScaleAuto;
|
int gConfigScale = style::kScaleAuto;
|
||||||
|
|
||||||
|
QString gDateFormat = qsl("dd.MM.yy");
|
||||||
QString gTimeFormat = qsl("hh:mm");
|
QString gTimeFormat = qsl("hh:mm");
|
||||||
|
|
||||||
RecentStickerPreload gRecentStickersPreload;
|
RecentStickerPreload gRecentStickersPreload;
|
||||||
|
|
|
@ -82,6 +82,7 @@ DeclareSetting(bool, Quit);
|
||||||
DeclareSetting(QByteArray, LocalSalt);
|
DeclareSetting(QByteArray, LocalSalt);
|
||||||
DeclareSetting(int, ScreenScale);
|
DeclareSetting(int, ScreenScale);
|
||||||
DeclareSetting(int, ConfigScale);
|
DeclareSetting(int, ConfigScale);
|
||||||
|
DeclareSetting(QString, DateFormat);
|
||||||
DeclareSetting(QString, TimeFormat);
|
DeclareSetting(QString, TimeFormat);
|
||||||
|
|
||||||
class DocumentData;
|
class DocumentData;
|
||||||
|
@ -110,6 +111,10 @@ DeclareSetting(QString, StartUrl);
|
||||||
|
|
||||||
DeclareSetting(int, OtherOnline);
|
DeclareSetting(int, OtherOnline);
|
||||||
|
|
||||||
|
inline void cChangeDateFormat(const QString &newFormat) {
|
||||||
|
if (!newFormat.isEmpty()) cSetDateFormat(newFormat);
|
||||||
|
}
|
||||||
|
|
||||||
inline void cChangeTimeFormat(const QString &newFormat) {
|
inline void cChangeTimeFormat(const QString &newFormat) {
|
||||||
if (!newFormat.isEmpty()) cSetTimeFormat(newFormat);
|
if (!newFormat.isEmpty()) cSetTimeFormat(newFormat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,6 +448,7 @@ rpl::producer<QString> Helper::infoLabelValue(
|
||||||
) | rpl::map([](const Support::UserInfo &info) {
|
) | rpl::map([](const Support::UserInfo &info) {
|
||||||
const auto time = Ui::FormatDateTime(
|
const auto time = Ui::FormatDateTime(
|
||||||
base::unixtime::parse(info.date),
|
base::unixtime::parse(info.date),
|
||||||
|
cDateFormat(),
|
||||||
cTimeFormat());
|
cTimeFormat());
|
||||||
return info.author + ", " + time;
|
return info.author + ", " + time;
|
||||||
});
|
});
|
||||||
|
|
|
@ -79,25 +79,28 @@ QString FormatProgressText(qint64 ready, qint64 total) {
|
||||||
total);
|
total);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FormatDateTime(QDateTime date, QString format) {
|
QString FormatDateTime(
|
||||||
|
QDateTime date,
|
||||||
|
QString dateFormat,
|
||||||
|
QString timeFormat) {
|
||||||
const auto now = QDateTime::currentDateTime();
|
const auto now = QDateTime::currentDateTime();
|
||||||
if (date.date() == now.date()) {
|
if (date.date() == now.date()) {
|
||||||
return tr::lng_mediaview_today(
|
return tr::lng_mediaview_today(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_time,
|
lt_time,
|
||||||
date.time().toString(format));
|
date.time().toString(timeFormat));
|
||||||
} else if (date.date().addDays(1) == now.date()) {
|
} else if (date.date().addDays(1) == now.date()) {
|
||||||
return tr::lng_mediaview_yesterday(
|
return tr::lng_mediaview_yesterday(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_time,
|
lt_time,
|
||||||
date.time().toString(format));
|
date.time().toString(timeFormat));
|
||||||
} else {
|
} else {
|
||||||
return tr::lng_mediaview_date_time(
|
return tr::lng_mediaview_date_time(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_date,
|
lt_date,
|
||||||
date.date().toString(u"dd.MM.yy"_q),
|
date.date().toString(dateFormat),
|
||||||
lt_time,
|
lt_time,
|
||||||
date.time().toString(format));
|
date.time().toString(timeFormat));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,10 @@ inline constexpr auto FileStatusSizeFailed = 0x7FFFFFF2;
|
||||||
[[nodiscard]] QString FormatSizeText(qint64 size);
|
[[nodiscard]] QString FormatSizeText(qint64 size);
|
||||||
[[nodiscard]] QString FormatDownloadText(qint64 ready, qint64 total);
|
[[nodiscard]] QString FormatDownloadText(qint64 ready, qint64 total);
|
||||||
[[nodiscard]] QString FormatProgressText(qint64 ready, qint64 total);
|
[[nodiscard]] QString FormatProgressText(qint64 ready, qint64 total);
|
||||||
[[nodiscard]] QString FormatDateTime(QDateTime date, QString format);
|
[[nodiscard]] QString FormatDateTime(
|
||||||
|
QDateTime date,
|
||||||
|
QString dateFormat,
|
||||||
|
QString timeFormat);
|
||||||
[[nodiscard]] QString FormatDurationText(qint64 duration);
|
[[nodiscard]] QString FormatDurationText(qint64 duration);
|
||||||
[[nodiscard]] QString FormatDurationWords(qint64 duration);
|
[[nodiscard]] QString FormatDurationWords(qint64 duration);
|
||||||
[[nodiscard]] QString FormatDurationAndSizeText(qint64 duration, qint64 size);
|
[[nodiscard]] QString FormatDurationAndSizeText(qint64 duration, qint64 size);
|
||||||
|
|
Loading…
Reference in New Issue