//该函数主要是对于nmea时间的处理
#ifndef __NMEA_TIME_H__
#define __NMEA_TIME_H__
#include "config.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _nmeaTIME
{
int year;
int mon; //这里竟然是0-11,而不是1-12
int day;
int hour;
int min;
int sec;
int hsec;
} nmeaTIME;
void nmea_time_now(nmeaTIME *t); //获得这个格式的时间
#ifdef __cplusplus
}
#endif
#endif
#include "nmea/time.h"
#ifdef NMEA_WIN
# pragma warning(disable: 4201)
//对于这个用法不熟的可参考Http://no001.blog.51cto.com/1142339/354181# pragma warning(disable: 4214)
# pragma warning(disable: 4115)
# include <
windows.h>
# pragma warning(default: 4201)
# pragma warning(default: 4214)
# pragma warning(default: 4115)
#else
# include <time.h>
#endif
#ifdef NMEA_WIN //充分利用宏定义。对于window.h函数库不熟,这个不是标准的c函数库,是widows的库
void nmea_time_now(nmeaTIME *stm)
{
SYSTEMTIME st;
GetSystemTime(&st);
stm->year = st.wYear - 1900;
stm->mon = st.wMonth - 1; //月份-1,,,0-11
stm->day = st.wDay;
stm->hour = st.wHour;
stm->min = st.wMinute;
stm->sec = st.wSecond;
stm->hsec = st.wMilliseconds / 10;
}
#else //这个地方,直接都使用<time.h>不就行了吗?既然time是标准的c函数,那个windows中肯定也有,那么为什么还要再单独调用window.h呢?
void nmea_time_now(nmeaTIME *stm)
{
time_t lt;
struct tm *tt;
time(<);
tt = gmtime(<);
stm->year = tt->tm_year;
stm->mon = tt->tm_mon;
stm->day = tt->tm_mday;
stm->hour = tt->tm_hour;
stm->min = tt->tm_min;
stm->sec = tt->tm_sec;
stm->hsec = 0;
}
#endif
0