QDate - wrong year [Solved]

  • 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

  • How should the Qt know which epoch this year is?

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

    good point. Is there anyway to fix?

  • 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);

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

  • 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...

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

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

  • @$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)

  • 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...

  • good point. ty

  • 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?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.