Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. localized translated autoname function using QDate and QTime or QDateTime
Forum Updated to NodeBB v4.3 + New Features

localized translated autoname function using QDate and QTime or QDateTime

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 367 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by
    #1

    He guys, I am trying to figure out if I can use QDateTime to come up with an autoname function that I know will always produce a unique name which is both translatable and localized. I was thinking something like: YYYY-MM-DDD-HHMMSS. What might that look like using QDateTime? Are there any examples of something similar online?

    JonBJ 1 Reply Last reply
    0
    • C Circuits

      @JonB So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS? Seems odd because any other format would require some kind of localization as it would be an American-centric format. Most of the rest of the world uses the YYYY/MM/DD format do they not?

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #4

      @Circuits said in localized translated autoname function using QDate and QTime or QDateTime:

      So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS?

      yes, with QDateTime::toString()

      Most of the rest of the world uses the YYYY/MM/DD format do they not?

      The world settled on the ISO 8601 format that you can get with dateTime.toString(Qt::ISODate)

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • C Circuits

        He guys, I am trying to figure out if I can use QDateTime to come up with an autoname function that I know will always produce a unique name which is both translatable and localized. I was thinking something like: YYYY-MM-DDD-HHMMSS. What might that look like using QDateTime? Are there any examples of something similar online?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @Circuits said in localized translated autoname function using QDate and QTime or QDateTime:

        What might that look like using QDateTime?

        Well it would look like whatever QDateTime says for your pattern. (Yours btw I don't think is valid, maybe you had ddd MMMM in mind?) Note that https://doc.qt.io/qt-5/qdatetime.html#toString-2 states:

        Note: If localized month and day names are desired, please switch to using QLocale::system().toString() as QDateTime methods shall change to use English (C locale) names at Qt 6.

        C 1 Reply Last reply
        3
        • JonBJ JonB

          @Circuits said in localized translated autoname function using QDate and QTime or QDateTime:

          What might that look like using QDateTime?

          Well it would look like whatever QDateTime says for your pattern. (Yours btw I don't think is valid, maybe you had ddd MMMM in mind?) Note that https://doc.qt.io/qt-5/qdatetime.html#toString-2 states:

          Note: If localized month and day names are desired, please switch to using QLocale::system().toString() as QDateTime methods shall change to use English (C locale) names at Qt 6.

          C Offline
          C Offline
          Circuits
          wrote on last edited by
          #3

          @JonB So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS? Seems odd because any other format would require some kind of localization as it would be an American-centric format. Most of the rest of the world uses the YYYY/MM/DD format do they not?

          VRoninV JonBJ 2 Replies Last reply
          0
          • C Circuits

            @JonB So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS? Seems odd because any other format would require some kind of localization as it would be an American-centric format. Most of the rest of the world uses the YYYY/MM/DD format do they not?

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #4

            @Circuits said in localized translated autoname function using QDate and QTime or QDateTime:

            So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS?

            yes, with QDateTime::toString()

            Most of the rest of the world uses the YYYY/MM/DD format do they not?

            The world settled on the ISO 8601 format that you can get with dateTime.toString(Qt::ISODate)

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2
            • C Circuits

              @JonB So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS? Seems odd because any other format would require some kind of localization as it would be an American-centric format. Most of the rest of the world uses the YYYY/MM/DD format do they not?

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #5

              @Circuits said in localized translated autoname function using QDate and QTime or QDateTime:

              So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS?

              In addition to what @VRonin wrote. It certainly does. If you clicked the link I gave you would see it recognises many such patterns, that's the whole point. The question is precisely which/what you are wanting.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved