jiveaxe
28th April 2012, 18:38
Hi, have a problem with localized date representation. Dates are in the following format:
2012-05-01
My system is using the it_IT locale as QLocale::system().name() confirms. But
date.toString(Qt::SystemLocaleShortDate)
returns the english string "1 May 2012" instead of the italian "1 Mag 2012"
Seems that the only option to have an italian localization is to use:
QLocale locale;
QLocale::setDefault(locale.name());
locale.toString(date, QLocale::ShortFormat)
But the returned string is "01/05/2012", while if using QLocale::LongFormat I got "martedì 1 maggio 2012" that is correct, but too long.
With locale.toString(date, "dd MMMM yyyy") I obtain the desired format but since I will release the code I would prefer a more clean solution.
Thanks.
2012-05-01
My system is using the it_IT locale as QLocale::system().name() confirms. But
date.toString(Qt::SystemLocaleShortDate)
returns the english string "1 May 2012" instead of the italian "1 Mag 2012"
Seems that the only option to have an italian localization is to use:
QLocale locale;
QLocale::setDefault(locale.name());
locale.toString(date, QLocale::ShortFormat)
But the returned string is "01/05/2012", while if using QLocale::LongFormat I got "martedì 1 maggio 2012" that is correct, but too long.
With locale.toString(date, "dd MMMM yyyy") I obtain the desired format but since I will release the code I would prefer a more clean solution.
Thanks.