Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-94603

When using QLocale::setDefault() the amText() returns "AM" and pmText() returns "PM" with languages which don't use AM/PM suffixes



    • Windows
    • b5bc3ee036575dd5a3eec1d6bd578738df7bd6ad


      When using QLocale::setDefault("de_DE") for setting the localization to German (or to any other localization which does not use pm or am suffixes) QLocale's DateTime format returns (0,2) for amText and for pmText like intended as there is no am or pm suffixes in use in the German language. But when amText and pmText is explicitly requested the Qt will fallback for providing "AM" and "PM" texts instead of "" which is the case when localization is based on system localization on Windows.

      These two methods are inconsistent with each other.
      I have attached an example which reproduces the problem.

      How to reproduce:
      1. Change the localization of system to German (Germany).
      2. Build and run the attached example with Qt 5.15.x
      3. Please look at the output. The am & pm are different when comparing the system localization and the localization from data used internally with Qt.

      The output is the following:
      empty (default from system) "de_DE" "" "" "dddd d. MMMM yyyy H.mm.ss" ""
      empty (after setDefault() ) "de_DE" "PM" "AM" "dddd, d. MMMM yyyy HH:mm:ss t" "PM"
      empty (after set to sysLocale) "de_DE" "" "" "dddd d. MMMM yyyy H.mm.ss" ""

      When they would be expected to be the same.


        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            Eddy Edward Welbourne
            foxxx Tuukka Kettunen
            0 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes