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. QDate - wrong year [Solved]
Qt 6.11 is out! See what's new in the release blog

QDate - wrong year [Solved]

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 6.7k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I have the following situation:

    @ QDate fixDate = QDate::fromString(QString("270912"), "ddMMyy");@

    the year returned is 1912. I do not understand why and how get the correct year.

    Thanks in advanc

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      How should the Qt know which epoch this year is?

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        [quote author="AcerExtensa" date="1348753653"]How should the Qt know which epoch this year is? [/quote]

        good point. Is there anyway to fix?

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          You can add 100 years for example... if you sure what only years from 21-31 century will be used...

          @
          QDate fixDate = QDate::fromString(QString("270912"), "ddMMyy").addYears (100);
          @

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            I see. I read that particular string from a nmea sentence... do you think adding 100 years is the good way to go?

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              I don't really know... but if there is no other option to get full sized year...
              Or you can do like it is an real-time date... and use epoch from current date...

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                ok- Thank you. I will add 100 years. In the next century I think I will be retired. So why bother?

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  Wait a second does gps nmea returns a year? I was thinking it returns only the utc time and not the date?

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    @$GPRMC,143322.34,A,0000.023,N,00000.000,W,21.60,0.00,270912,0.0,E,A*1E@

                    270912 is the utc date
                    143322.34 is te utc time (hhmmss.zz)

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      I have better idea!
                      in year 1912 there was no GPS at all, and of cause no nmea format...

                      bq. 1973 Decision to develop a satellite navigation system based on the systems TRANSIT, TIMATION und 621B of the U.S. Air Force and the U.S. Navy.

                      You will be on the safe side to convert all dates after 1970 into 19__ format and all dates below into 20__ format...

                      1 Reply Last reply
                      0
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #11

                        good point. ty

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #12

                          Actually, I think it is a save bet to use this century always. How big is the chance that you'll be processing old nmea logs from before the year 2000?

                          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