目的:
由于GPS模块传输数据和北京时间存在时差,因此需要对时间进行修正
修正程序:
//algrithm of calibrate GPS time
RTC_Time.Hours += 8;
if (RTC_Time.Hours > 23)
{
RTC_Time.Hours -= 24;
RTC_Date.Date += 1;
uint8_t ucaDays[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if ((RTC_Date.Year % 4) == 0)
{
ucaDays[1] = 29;
}
if (RTC_Date.Date > ucaDays[RTC_Date.Month--])
{
RTC_Date.Date = RTC_Date.Date - ucaDays[RTC_Date.Month--];
RTC_Date.Month++;
if (RTC_Date.Month > 12)
{
RTC_Date.Month = 1;
RTC_Date.Year++;
}
}
}