From 829c1d4110f56bdd32a346b67aa9cf6cea8f693d Mon Sep 17 00:00:00 2001 From: Daniel Albers Date: Mon, 10 Dec 2012 15:33:52 +0100 Subject: [PATCH] Display timestamps using the application locale Reverts configuration of timestamp formats via translation files. Formatting of timestamps and such should completely move from core to client at some point. Fixes #1199 --- src/core/eventstringifier.cpp | 23 +++++++++++------------ src/uisupport/uistyle.cpp | 4 +--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/core/eventstringifier.cpp b/src/core/eventstringifier.cpp index ac0a3ac1..e7ad58d6 100644 --- a/src/core/eventstringifier.cpp +++ b/src/core/eventstringifier.cpp @@ -457,14 +457,13 @@ void EventStringifier::processIrcEvent317(IrcEvent *e) if (e->params().count() > 3) { // if we have more then 3 params we have the above mentioned "real life" situation QDateTime loginTime = QDateTime::fromTime_t(e->params()[2].toInt()); - //: Time format. See http://qt-project.org/doc/qt-4.8/qdatetime.html#toString - QString formattedLoginTime = loginTime.toString(tr("MMMM d yyyy hh:mm")); - displayMsg(e, Message::Server, tr("[Whois] %1 is logged in since %2").arg(e->params()[0], formattedLoginTime)); + displayMsg(e, Message::Server, tr("[Whois] %1 is logged in since %2") + .arg(e->params()[0], QLocale().toString(loginTime, QLocale().dateTimeFormat()))); } - //: Time format. See http://qt-project.org/doc/qt-4.8/qdatetime.html#toString - QString idlingSince = e->timestamp().toLocalTime().addSecs(-idleSecs).toString(tr("MMMM d yyyy hh:mm")); + QDateTime idlingSince = e->timestamp().toLocalTime().addSecs(-idleSecs); displayMsg(e, Message::Server, tr("[Whois] %1 is idling for %2 (since %3)") - .arg(e->params()[0], secondsToString(idleSecs), idlingSince)); + .arg(e->params()[0], secondsToString(idleSecs), + QLocale().toString(idlingSince, QLocale().dateTimeFormat()))); } @@ -563,9 +562,9 @@ void EventStringifier::processIrcEvent329(IrcEvent *e) return; } QDateTime time = QDateTime::fromTime_t(unixtime); - //: Time format. See http://qt-project.org/doc/qt-4.8/qdatetime.html#toString - QString formattedTime = time.toString(tr("MMMM d yyyy hh:mm")); - displayMsg(e, Message::Topic, tr("Channel %1 created on %2").arg(channel, formattedTime), QString(), channel); + displayMsg(e, Message::Topic, tr("Channel %1 created on %2") + .arg(channel, QLocale().toString(time, QLocale().dateTimeFormat())), + QString(), channel); } @@ -608,10 +607,10 @@ void EventStringifier::processIrcEvent333(IrcEvent *e) return; QString channel = e->params().first(); - //: Time format. See http://qt-project.org/doc/qt-4.8/qdatetime.html#toString - QString topicSetTime = QDateTime::fromTime_t(e->params()[2].toInt()).toString(tr("MMMM d yyyy hh:mm")); + QDateTime topicSetTime = QDateTime::fromTime_t(e->params()[2].toInt()); displayMsg(e, Message::Topic, tr("Topic set by %1 on %2") - .arg(e->params()[1], topicSetTime), QString(), channel); + .arg(e->params()[1], + QLocale().toString(topicSetTime, QLocale().dateTimeFormat()), QString(), channel)); } diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 549f5a9f..1e78e385 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -688,10 +688,8 @@ void UiStyle::StyledMessage::style() const t = tr("%1").arg(txt); break; case Message::DayChange: { - //: Date format. See http://qt-project.org/doc/qt-4.8/qdate.html#toString - QString newDate = timestamp().toString(tr("MMMM d yyyy")); //: Day Change Message - t = tr("{Day changed to %1}").arg(newDate); + t = tr("{Day changed to %1}").arg(QLocale().toString(timestamp(), QLocale().dateFormat())); } break; case Message::Topic: -- 2.20.1