I need to synchronize two sensors from UTC to unix time. The first one is an GPS which yields an NMEA GPGGA file, where UTC timestamp has the format "HHmmss.SSS". As an example "042803.00" is "4:28:03" AM and zero milliseconds.
The second sensor yields an unix time without leap seconds.
Is there an MATLAB function which I can use? I'm especially interested in an solution which respects leap seconds? My first approach is to convert the unix time into utc:
sensor=datetime(unix_timestamp,'ConvertFrom','posixtime')
Unfortunately the argument posixtime does not support leap seconds. Then I take the utc timestamp from the NMEA file:
gps=datetime(utc_timestamp,'InputFormat','HHmmss.SSS','TimeZone','UTC')
Now since i don't have any day, year, month in my NMEA protocoll, I take it from the unix_timestamp
gps.Day=sensor.Daygps.Month=sensor.Monthgps.Year=sensor.Year
Any Idea how to do it better? What is the risk if i take the year,month,day from the unix timestamp without leap seconds?
Now I want to transfer the gps time into unix time with:
unix_time_gps=posixtime(gps)
This does not work since posixtime does not respect leap seconds.
How do I achieve this?
Thank you
Best Answer