nmealib解析-----(3)---
短信预约 -IT技能 免费直播动态提醒
//该函数主要是对于nmea时间的处理
#ifndef __NMEA_TIME_H__
#define __NMEA_TIME_H__
#define __NMEA_TIME_H__
#include "config.h"
#ifdef __cplusplus
extern "C" {
#endif
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
#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
# 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;
{
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;
}
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_t lt;
struct tm *tt;
time(<);
tt = gmtime(<);
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;
}
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
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341