1
0
forked from mirrors/0ad

Moves CreateDateTimeInstance from the public L10n header to its implementation.

This was SVN commit r25042.
This commit is contained in:
vladislavbelov
2021-03-12 09:11:22 +00:00
parent d6ddc4f3ac
commit 4d58b0729e
2 changed files with 31 additions and 32 deletions
+27 -16
View File
@@ -69,6 +69,33 @@ void ReadPoIntoDictionary(const std::string& poContent, tinygettext::Dictionary*
}
}
/**
* Creates an ICU date formatted with the specified settings.
*
* @param type Whether formatted dates must show both the date and the time,
* only the date or only the time.
* @param style ICU style to format dates by default.
* @param locale Locale that the date formatter should use to parse strings.
* It has no relevance for date formatting, only matters for date
* parsing.
* @return ICU date formatter.
*/
icu::DateFormat* CreateDateTimeInstance(const L10n::DateTimeType& type, const icu::DateFormat::EStyle& style, const icu::Locale& locale)
{
switch (type)
{
case L10n::Date:
return icu::SimpleDateFormat::createDateInstance(style, locale);
case L10n::Time:
return icu::SimpleDateFormat::createTimeInstance(style, locale);
case L10n::DateTime:
default:
return icu::SimpleDateFormat::createDateTimeInstance(style, style, locale);
}
}
} // anonymous namespace
void L10n::DictionaryDeleter::operator()(tinygettext::Dictionary* dictionary)
@@ -551,19 +578,3 @@ void L10n::LoadListOfAvailableLocales()
availableLocales.push_back(std::move(locale));
}
}
icu::DateFormat* L10n::CreateDateTimeInstance(const L10n::DateTimeType& type, const icu::DateFormat::EStyle& style, const icu::Locale& locale) const
{
switch(type)
{
case Date:
return icu::SimpleDateFormat::createDateInstance(style, locale);
case Time:
return icu::SimpleDateFormat::createTimeInstance(style, locale);
case DateTime:
default:
return icu::SimpleDateFormat::createDateTimeInstance(style, style, locale);
}
}
+4 -16
View File
@@ -34,7 +34,7 @@
namespace tinygettext
{
class Dictionary;
class Dictionary;
}
#define g_L10n L10n::GetSingleton()
@@ -56,7 +56,7 @@ public:
L10n();
/**
* Handles the descruction of L10n.
* Handles the destruction of L10n.
*
* Never destroy the L10n singleton manually. It must run as long as the
* game runs, and it is destroyed automatically when you quit the game.
@@ -68,7 +68,8 @@ public:
*
* @sa LocalizeDateTime()
*/
enum DateTimeType {
enum DateTimeType
{
DateTime, ///< Both date and time.
Date, ///< Only date.
Time ///< Only time.
@@ -563,19 +564,6 @@ private:
* @sa availableLocales
*/
void LoadListOfAvailableLocales();
/**
* Creates an ICU date formatted with the specified settings.
*
* @param type Whether formatted dates must show both the date and the time,
* only the date or only the time.
* @param style ICU style to format dates by default.
* @param locale Locale that the date formatter should use to parse strings.
* It has no relevance for date formatting, only matters for date
* parsing.
* @return ICU date formatter.
*/
icu::DateFormat* CreateDateTimeInstance(const DateTimeType& type, const icu::DateFormat::EStyle& style, const icu::Locale& locale) const;
};
#endif // INCLUDED_L10N