KLocale::formatDate()

David Faure faure at kde.org
Sun Feb 4 20:39:53 GMT 2007


On Saturday 03 February 2007, Adriaan de Groot wrote:
> Is there a good reason why there is no static member KLocale::formatDate() 
> that takes a format string (instead of using the locale format string)? That 
> would make the special processing available for the escapes available in more 
> places.
> 
> I'm asking in particular because I found some code that does:
> 
> QString oldFormat = KGlobal::locale()->dateFormat();
> KGlobal::locale()->setDateFormat(newFormat);
> QString formattedDate = KGlobal::locale()->formatDate(date);
> KGlobal::locale()->setDateFormat(oldFormat);

Why doesn't this code create a different KLocale object, set the date format on it, 
and use it to format dates? I believe kspread does this already.
It has the benefit of not messing up the global locale, and it doesn't need massive api duplication
(there are quite a number of methods about formatting and reading dates and times in klocale).

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list