Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
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?
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
andre last edited by
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?