diff options
author | Mike FABIAN <mike.fabian@basyskom.de> | 2010-09-09 17:55:42 +0200 |
---|---|---|
committer | Mike FABIAN <mike.fabian@basyskom.de> | 2010-09-10 14:01:47 +0200 |
commit | 7c23f930476e33e6ca0869863075e0540e06dba6 (patch) | |
tree | 8d5b5e43473039f0f91bed3a8891820657b5e67e /src | |
parent | 458cc521ea0e154692705f7c703a6b721ec4bbb5 (diff) |
Changes: add MLocale::TimeFormat24h MLocale::defaultTimeFormat24h()
RevBy: TrustMe
Details:
Needed for
https://projects.maemo.org/bugzilla/show_bug.cgi?id=186771
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/i18n/mlocale.cpp | 17 | ||||
-rw-r--r-- | src/corelib/i18n/mlocale.h | 39 | ||||
-rw-r--r-- | src/corelib/i18n/mlocale_p.h | 2 | ||||
-rw-r--r-- | src/icu-extradata/4.4.1/ms_BN.txt | 21 | ||||
-rw-r--r-- | src/icu-extradata/icu-extradata.pro | 3 |
5 files changed, 80 insertions, 2 deletions
diff --git a/src/corelib/i18n/mlocale.cpp b/src/corelib/i18n/mlocale.cpp index 1b842b93..9576bad4 100644 --- a/src/corelib/i18n/mlocale.cpp +++ b/src/corelib/i18n/mlocale.cpp @@ -277,7 +277,7 @@ icu::DateFormatSymbols *MLocalePrivate::createDateFormatSymbols(const icu::Local #endif #ifdef HAVE_ICU -static bool isTwelveHours(const QString &icuFormatQString) +bool MLocalePrivate::isTwelveHours(const QString &icuFormatQString) const { if (icuFormatQString.contains('\'')) { bool isQuoted = false; @@ -1460,6 +1460,21 @@ MLocale::TimeFormat24h MLocale::timeFormat24h() const } #ifdef HAVE_ICU +MLocale::TimeFormat24h MLocale::defaultTimeFormat24h() const +{ + Q_D(const MLocale); + QString defaultTimeShortFormat + = d->icuFormatString(MLocale::DateNone, MLocale::TimeShort, + d->_calendarType, + MLocale::LocaleDefaultTimeFormat24h); + if (d->isTwelveHours(defaultTimeShortFormat)) + return MLocale::TwelveHourTimeFormat24h; + else + return MLocale::TwentyFourHourTimeFormat24h; +} +#endif + +#ifdef HAVE_ICU MCollator MLocale::collator() const { return MCollator(*this); diff --git a/src/corelib/i18n/mlocale.h b/src/corelib/i18n/mlocale.h index 50bc4771..678dfeca 100644 --- a/src/corelib/i18n/mlocale.h +++ b/src/corelib/i18n/mlocale.h @@ -363,15 +363,54 @@ public: /*! * \brief Sets whether 24 hour clock, 12 hour clock or default is used + * + * \param timeFormat24h enum to choose the 12/24 hour mode + * + * If MLocale::TwelveHourTimeFormat24h is given as the parameter + * the locale is forced to use 24 hour mode, if + * MLocale::TwentyFourHourTimeFormat24h is given as the parameter + * the locale is forced to use 12 hour mode. + * If MLocale::LocaleDefaultTimeFormat24 is given as the parameter + * the locale is neither forced to use 12 nor 24 hour mode, + * it uses the default for this locale then. + * + * \sa timeFormat24h() const + * \sa defaultTimeFormat24h() const */ void setTimeFormat24h(TimeFormat24h timeFormat24h); /*! * \brief Returns whether 24 hour clock, 12 hour clock or default is used + * + * returns MLocale::TwelveHourTimeFormat24h if 12 hour mode + * is forced for this locale, + * returns MLocale::TwentyFourHourTimeFormat24h if 24 hour mode + * is forced for this locale and returns + * MLocale::LocaleDefaultTimeFormat24h if the 12/24 hour mode + * is not forced but left to what this locale would use by default. + * + * \sa setTimeFormat24h(TimeFormat24h timeFormat24h) + * \sa defaultTimeFormat24h() const */ TimeFormat24h timeFormat24h() const; /*! + * \brief Returns whether 24 hour or 12 hour format is used by default + * + * returns MLocale::TwelveHourTimeFormat24h if this locale would use + * 12 hour mode by default and MLocale::TwentyFourHourTimeFormat24h + * if this locale would use 24 hour mode by default. + * + * Actually this locale may use a different mode because + * the default can be overridden, this method shows only + * what the default would be if it were not overridden. + * + * \sa timeFormat24h() const + * \sa setTimeFormat24h(TimeFormat24h timeFormat24h) + */ + TimeFormat24h defaultTimeFormat24h() const; + + /*! * \brief Returns a MCollator which compares QStrings based on language/country/collation rules */ MCollator collator() const; diff --git a/src/corelib/i18n/mlocale_p.h b/src/corelib/i18n/mlocale_p.h index 73e73f86..26349736 100644 --- a/src/corelib/i18n/mlocale_p.h +++ b/src/corelib/i18n/mlocale_p.h @@ -87,6 +87,8 @@ public: static icu::DateFormatSymbols *createDateFormatSymbols(const icu::Locale &locale); + // checks if an ICU format string is a twelve hour format string or not + bool isTwelveHours(const QString &icuFormatQString) const; // converts an ICU date format to 24 hour clock void dateFormatTo24h(icu::DateFormat *df) const; // converts an ICU date format to 12 hour clock diff --git a/src/icu-extradata/4.4.1/ms_BN.txt b/src/icu-extradata/4.4.1/ms_BN.txt new file mode 100644 index 00000000..69160bd2 --- /dev/null +++ b/src/icu-extradata/4.4.1/ms_BN.txt @@ -0,0 +1,21 @@ +ms_BN{ + calendar{ + gregorian{ + DateTimePatterns{ + "H:mm:ss zzzz", + "H:mm:ss z", + "H:mm:ss", + "H:mm", + "dd MMMM y", + "y MMMM d", + "dd/MM/yyyy", + "yyyy-MM-dd", + "{1} {0}", + "{1} {0}", + "{1} {0}", + "{1} {0}", + "{1} {0}", + } + } + } +} diff --git a/src/icu-extradata/icu-extradata.pro b/src/icu-extradata/icu-extradata.pro index e47423e5..8159f074 100644 --- a/src/icu-extradata/icu-extradata.pro +++ b/src/icu-extradata/icu-extradata.pro @@ -7,7 +7,8 @@ ICUUSRDATA = $$replace(ICUDATA, icudt, usrdt) # for example “usrdt44l” greaterThan(ICUVERSION, 4.4) { LOCALESTXT = $${ICUVERSION}/fi.txt \ - $${ICUVERSION}/it.txt + $${ICUVERSION}/it.txt \ + $${ICUVERSION}/ms_BN.txt LANGTXT = $${ICUVERSION}/lang/de_CH.txt REGIONTXT = $${ICUVERSION}/region/de_CH.txt } else { |