[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdeplasma-addons] applets/fuzzy-clock: Fuzzy Clock: Use proper date api
From:       John Layt <jlayt () kde ! org>
Date:       2012-03-31 22:31:52
Message-ID: 20120331223152.385B8A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit 6427816afb476dcc30d7be2457d2a6bd9ec746cf by John Layt.
Committed on 01/04/2012 at 00:30.
Pushed by jlayt into branch 'master'.

Fuzzy Clock: Use proper date api

Use the correct date api instead of a temp locale. KF5 prep.

M  +5    -9    applets/fuzzy-clock/fuzzyClock.cpp

http://commits.kde.org/kdeplasma-addons/6427816afb476dcc30d7be2457d2a6bd9ec746cf

diff --git a/applets/fuzzy-clock/fuzzyClock.cpp b/applets/fuzzy-clock/fuzzyClock.cpp
index d67e912..2cd189d 100644
--- a/applets/fuzzy-clock/fuzzyClock.cpp
+++ b/applets/fuzzy-clock/fuzzyClock.cpp
@@ -28,6 +28,7 @@
 #include <KColorScheme>
 #include <KConfigDialog>
 #include <KDebug>
+#include <KCalendarSystem>
 
 #include <Plasma/Theme>
 
@@ -296,13 +297,9 @@ void Clock::calculateDateString()
             return;
         }
 
-    KLocale tmpLocale(*KGlobal::locale());
-    tmpLocale.setDateFormat("%e"); // day number of the month
-    QString day = tmpLocale.formatDate(m_date);
-    tmpLocale.setDateFormat("%b"); // short form of the month
-    QString month = tmpLocale.formatDate(m_date);
-    tmpLocale.setDateFormat("%Y"); // the year with four digits
-    QString year = tmpLocale.formatDate(m_date);
+    QString day = KGlobal::locale()->calendar()->formatDate(m_date, KLocale::Day, \
KLocale::ShortNumber); +    QString month = \
KGlobal::locale()->calendar()->formatDate(m_date, KLocale::Month, \
KLocale::ShortName); +    QString year = \
KGlobal::locale()->calendar()->formatDate(m_date, KLocale::Year, \
KLocale::LongNumber);  
     //Copied from the digital-clock
     if (m_showDate) {
@@ -317,8 +314,7 @@ void Clock::calculateDateString()
                                 "%1 %2", day, month);
         }
         if (m_showDay) {
-            tmpLocale.setDateFormat("%a"); // short weekday
-            QString weekday = tmpLocale.formatDate(m_date);
+            QString weekday = KGlobal::locale()->calendar()->formatDate(m_date, \
KLocale::DayOfWeek, KLocale::ShortName);  m_dateString = i18nc("@label Day of the \
week with date: "  "%1 short day name, %2 short date",
                                 "%1, %2", weekday, m_dateString);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic