Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Gregorian date and time operations

The stdTime interface provides functions that operate on Gregorian calendar date and time values. It can be used to convert between Gregorian units and a numeric offset in seconds from some fixed point in time, such as the time offset returned from the user clock.

In the Gregorian calendar, a year consists of 365 days (366 in a leap year). Time is expressed is hours, minutes, and seconds.

Converting a time offset to a Gregorian date and time

To convert the time returned from the user clock to a Gregorian date and time, an application can call stdTime_AddSeconds() to add the offset to the epoch and return the Gregorian date and time values. For example:

nErr = stdtime_AddSeconds(&dtGPSEpoch, pMe->Seconds, &pMe->GregDateTime);

Converting a Gregorian date and time to an offset

To convert a Gregorian date and time into an offset from the epoch, an application can call stdTime_GetDiffSeconds(), which returns the difference between two times, in seconds. For example:

nErr = stdtime_GetDiffSeconds(&pMe->GregDateTime, &dtGPSEpoch, &pMe->Difference);