diff options
author | pieh <misiek.piechowiak@gmail.com> | 2011-08-29 23:32:43 +0200 |
---|---|---|
committer | pieh <misiek.piechowiak@gmail.com> | 2011-08-29 23:32:43 +0200 |
commit | 74bb7db6da4a9510b586d7749cad1e18d0cd9872 (patch) | |
tree | 18f5545e0fb2f58ef6a7dbcb35571e8afa0ef685 | |
parent | a1246de31894aff63fac85a35ed2b63c53f9948e (diff) |
expose date custom formating by refactoring CDateTime::GetAsLocalizedDate
-rw-r--r-- | xbmc/XBDateTime.cpp | 17 | ||||
-rw-r--r-- | xbmc/XBDateTime.h | 1 |
2 files changed, 11 insertions, 7 deletions
diff --git a/xbmc/XBDateTime.cpp b/xbmc/XBDateTime.cpp index 53d467d4a7..5e97385d5d 100644 --- a/xbmc/XBDateTime.cpp +++ b/xbmc/XBDateTime.cpp @@ -1116,9 +1116,12 @@ CStdString CDateTime::GetAsLocalizedTime(const CStdString &format, bool withSeco CStdString CDateTime::GetAsLocalizedDate(bool longDate/*=false*/, bool withShortNames/*=true*/) const { - CStdString strOut; + return GetAsLocalizedDate(g_langInfo.GetDateFormat(longDate), withShortNames); +} - const CStdString& strFormat=g_langInfo.GetDateFormat(longDate); +CStdString CDateTime::GetAsLocalizedDate(const CStdString &strFormat, bool withShortNames/*=true*/) const +{ + CStdString strOut; SYSTEMTIME dateTime; GetAsSystemTime(dateTime); @@ -1150,7 +1153,7 @@ CStdString CDateTime::GetAsLocalizedDate(bool longDate/*=false*/, bool withShort strPart.Replace("''", "'"); strOut+=strPart; } - else if (c=='D') // parse days + else if (c=='D' || c=='d') // parse days { int partLength=0; @@ -1178,11 +1181,11 @@ CStdString CDateTime::GetAsLocalizedDate(bool longDate/*=false*/, bool withShort { int wday = dateTime.wDayOfWeek; if (wday < 1 || wday > 7) wday = 7; - str = g_localizeStrings.Get((withShortNames ? 40 : 10) + wday); + str = g_localizeStrings.Get(((withShortNames || c =='d') ? 40 : 10) + wday); } strOut+=str; } - else if (c=='M') // parse month + else if (c=='M' || c=='m') // parse month { int partLength=0; @@ -1210,11 +1213,11 @@ CStdString CDateTime::GetAsLocalizedDate(bool longDate/*=false*/, bool withShort { int wmonth = dateTime.wMonth; if (wmonth < 1 || wmonth > 12) wmonth = 12; - str = g_localizeStrings.Get((withShortNames ? 50 : 20) + wmonth); + str = g_localizeStrings.Get(((withShortNames || c =='m') ? 50 : 20) + wmonth); } strOut+=str; } - else if (c=='Y') // parse year + else if (c=='Y' || c =='y') // parse year { int partLength=0; diff --git a/xbmc/XBDateTime.h b/xbmc/XBDateTime.h index f092c76a52..d4a36fea13 100644 --- a/xbmc/XBDateTime.h +++ b/xbmc/XBDateTime.h @@ -184,6 +184,7 @@ public: CStdString GetAsDBDateTime() const; CStdString GetAsDBDate() const; CStdString GetAsLocalizedDate(bool longDate=false, bool withShortNames=true) const; + CStdString GetAsLocalizedDate(const CStdString &strFormat, bool withShortNames=true) const; CStdString GetAsLocalizedTime(const CStdString &format, bool withSeconds=true) const; CStdString GetAsLocalizedDateTime(bool longDate=false, bool withSeconds=true) const; CStdString GetAsRFC1123DateTime() const; |