From: Lasse Liehu Date: Tue, 11 Sep 2012 21:43:05 +0000 (+0300) Subject: Better time formatting by using an explicit format X-Git-Tag: 0.9-beta1~46 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=c64a887d0f05222590299fb2bb8d56fa9fadb16d;hp=42bade02f5352701d4603c72a341f04ea05922c5 Better time formatting by using an explicit format The default format QDateTime::toString uses isn't very good Also make it possible for translators to change the format --- diff --git a/src/core/eventstringifier.cpp b/src/core/eventstringifier.cpp index dcf48aa7..ac0a3ac1 100644 --- a/src/core/eventstringifier.cpp +++ b/src/core/eventstringifier.cpp @@ -457,10 +457,14 @@ 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()); - displayMsg(e, Message::Server, tr("[Whois] %1 is logged in since %2").arg(e->params()[0], loginTime.toString())); + //: 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)); } + //: 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")); displayMsg(e, Message::Server, tr("[Whois] %1 is idling for %2 (since %3)") - .arg(e->params()[0], secondsToString(idleSecs), e->timestamp().toLocalTime().addSecs(-idleSecs).toString())); + .arg(e->params()[0], secondsToString(idleSecs), idlingSince)); } @@ -559,7 +563,9 @@ void EventStringifier::processIrcEvent329(IrcEvent *e) return; } QDateTime time = QDateTime::fromTime_t(unixtime); - displayMsg(e, Message::Topic, tr("Channel %1 created on %2").arg(channel, time.toString()), QString(), channel); + //: 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); } @@ -602,8 +608,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")); displayMsg(e, Message::Topic, tr("Topic set by %1 on %2") - .arg(e->params()[1], QDateTime::fromTime_t(e->params()[2].toInt()).toString()), QString(), channel); + .arg(e->params()[1], topicSetTime), QString(), channel); } diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 6bd84941..549f5a9f 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -687,8 +687,12 @@ void UiStyle::StyledMessage::style() const //: Error Message 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(timestamp().toString()); + t = tr("{Day changed to %1}").arg(newDate); + } break; case Message::Topic: //: Topic Message