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

Date().toLocaleString() doesn't work correctly, ignores all arguments

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.4.0 RC
    • 5.3.2
    • Documentation
    • None
    • Windows 7 - MinGW 4.8.2
    • 4e7c588f027f6a846fc343975bc8bcce5f69f6ff

    Description

      The Date().toLocaleString() method does not what is described in the documenation. It seems that all arguments are ignored, it produces the same output as Date().toString().
      Workaround: Using Qt.formatDateTime() instead.

      The following code produced the output in the image:

      Unable to find source-code formatter for language: qml. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      import QtQuick 2.2
      
      Rectangle {
          width: 360
          height: 360
      
          Column {
              anchors.centerIn: parent
      
              Text {
                  text: Qt.formatDateTime(new Date, "dd.MM.yyyy hh:mm:ss")
              }
              Text {
                  text: Date().toLocaleString(Qt.locale(), "dd.MM.yyyy hh:mm:ss")
              }
              Text {
                  text: Date().toLocaleString(Qt.locale(), Locale.ShortFormat)
              }
              Text {
                  text: Date().toLocaleString(Qt.locale("en_US"), Locale.LongFormat)
              }
              Text {
                  text: Date().toLocaleString(Qt.locale("de_DE"), Locale.LongFormat)
              }
              Text {
                  text: Date().toLocaleString(Qt.locale("de_DE"))
              }
          }
      }
      

      Attachments

        1. date_formating.png
          17 kB
          Timo Zimmermann
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            veshivas Venugopal Shivashankar
            mrbluesky Timo Zimmermann
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes