Change date/time formats
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 9 Apr 2013 20:57:21 +0000 (22:57 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 9 Apr 2013 20:57:21 +0000 (22:57 +0200)
As some date strings are generated core-side, and servers might have set
a different locale than connected clients, we would like to avoid localized
date strings. As Qt4 also doesn't allow to display a time zone (offset) without
also localizing the string, we convert all core-side times into UTC and display
them in ISO format.

The daychange message, however, is generated client-side and thus can be shown
according to application or system locale.
 we would like to avoid localized
dates

src/core/eventstringifier.cpp
src/uisupport/uistyle.cpp

index 26a2bbe..787bac5 100644 (file)
@@ -461,14 +461,14 @@ void EventStringifier::processIrcEvent317(IrcEvent *e)
     int idleSecs = e->params()[1].toInt();
 
     if (e->params().count() > 3) { // if we have more then 3 params we have the above mentioned "real life" situation
     int idleSecs = e->params()[1].toInt();
 
     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());
+        QDateTime loginTime = QDateTime::fromTime_t(e->params()[2].toInt()).toUTC();
         displayMsg(e, Message::Server, tr("[Whois] %1 is logged in since %2")
         displayMsg(e, Message::Server, tr("[Whois] %1 is logged in since %2")
-           .arg(e->params()[0], QLocale().toString(loginTime, QLocale().dateTimeFormat())));
+           .arg(e->params()[0], loginTime.toString("yyyy-MM-dd hh:mm:ss UTC")));
     }
     }
-    QDateTime idlingSince = e->timestamp().toLocalTime().addSecs(-idleSecs);
+    QDateTime idlingSince = e->timestamp().toLocalTime().addSecs(-idleSecs).toUTC();
     displayMsg(e, Message::Server, tr("[Whois] %1 is idling for %2 (since %3)")
         .arg(e->params()[0], secondsToString(idleSecs),
     displayMsg(e, Message::Server, tr("[Whois] %1 is idling for %2 (since %3)")
         .arg(e->params()[0], secondsToString(idleSecs),
-            QLocale().toString(idlingSince, QLocale().dateTimeFormat())));
+            idlingSince.toString("yyyy-MM-dd hh:mm:ss UTC")));
 }
 
 
 }
 
 
@@ -566,9 +566,9 @@ void EventStringifier::processIrcEvent329(IrcEvent *e)
         qWarning() << Q_FUNC_INFO << "received invalid timestamp:" << e->params()[1];
         return;
     }
         qWarning() << Q_FUNC_INFO << "received invalid timestamp:" << e->params()[1];
         return;
     }
-    QDateTime time = QDateTime::fromTime_t(unixtime);
+    QDateTime time = QDateTime::fromTime_t(unixtime).toUTC();
     displayMsg(e, Message::Topic, tr("Channel %1 created on %2")
     displayMsg(e, Message::Topic, tr("Channel %1 created on %2")
-        .arg(channel, QLocale().toString(time, QLocale().dateTimeFormat())),
+        .arg(channel, time.toString("yyyy-MM-dd hh:mm:ss UTC")),
        QString(), channel);
 }
 
        QString(), channel);
 }
 
@@ -612,10 +612,10 @@ void EventStringifier::processIrcEvent333(IrcEvent *e)
         return;
 
     QString channel = e->params().first();
         return;
 
     QString channel = e->params().first();
-    QDateTime topicSetTime = QDateTime::fromTime_t(e->params()[2].toInt());
+    QDateTime topicSetTime = QDateTime::fromTime_t(e->params()[2].toInt()).toUTC();
     displayMsg(e, Message::Topic, tr("Topic set by %1 on %2")
         .arg(e->params()[1],
     displayMsg(e, Message::Topic, tr("Topic set by %1 on %2")
         .arg(e->params()[1],
-            QLocale().toString(topicSetTime, QLocale().dateTimeFormat())), QString(), channel);
+            topicSetTime.toString("yyyy-MM-dd hh:mm:ss UTC")), QString(), channel);
 }
 
 
 }
 
 
index df23a62..5fd929a 100644 (file)
@@ -717,7 +717,7 @@ void UiStyle::StyledMessage::style() const
     case Message::DayChange:
     {
         //: Day Change Message
     case Message::DayChange:
     {
         //: Day Change Message
-        t = tr("{Day changed to %1}").arg(QLocale().toString(timestamp(), QLocale().dateFormat()));
+        t = tr("{Day changed to %1}").arg(timestamp().date().toString(Qt::DefaultLocaleLongDate));
     }
         break;
     case Message::Topic:
     }
         break;
     case Message::Topic: