R
Ray Mitchell
Hello,
I need to be able to calculate the number of GPS seconds that have elapsed
between two struct tm times. My first thought was to use either mkgmtime or
mktime to convert them both to calendar time, then use difftime to compute
the difference in seconds. It then occurred to me, however, that the
difference would probably include any leap seconds that might have been
inserted between the two times, since most of the time functions seem to have
an underlying UTC reference.
Since I am working with GPS time, where there are no such things as leap
seconds, this presents a problem. One solution, of course, would be to
simply take note of the precise dates and times where leap seconds have been
inserted and if my time range includes one or more of these points, merely
subtract off an appropriate number of seconds from the difference produced by
difftime. However, it seems that there should be a better way, since my code
would have to be modified when the next leap second is inserted.
So I guess my first question is whether mkgmtime or mktime actually do
include leap seconds, and if so, does anyone have a better solution than I've
suggested?
Thanks,
Ray
I need to be able to calculate the number of GPS seconds that have elapsed
between two struct tm times. My first thought was to use either mkgmtime or
mktime to convert them both to calendar time, then use difftime to compute
the difference in seconds. It then occurred to me, however, that the
difference would probably include any leap seconds that might have been
inserted between the two times, since most of the time functions seem to have
an underlying UTC reference.
Since I am working with GPS time, where there are no such things as leap
seconds, this presents a problem. One solution, of course, would be to
simply take note of the precise dates and times where leap seconds have been
inserted and if my time range includes one or more of these points, merely
subtract off an appropriate number of seconds from the difference produced by
difftime. However, it seems that there should be a better way, since my code
would have to be modified when the next leap second is inserted.
So I guess my first question is whether mkgmtime or mktime actually do
include leap seconds, and if so, does anyone have a better solution than I've
suggested?
Thanks,
Ray