从GPS获取的时间为UTC时间的年,月,日,时,分,秒格式,希望转换成unix时间戳,C中time.h 提供函数mktime();将struct tm类型的结构体数据转换成unix时间戳,struct tm {
int tm_sec; /* seconds after the minute, 0 to 60
(0 - 60 allows for the occasional leap second) */
int tm_min; /* minutes after the hour, 0 to 59 */
int tm_hour; /* hours since midnight, 0 to 23 */
int tm_mday; /* day of the month, 1 to 31 */
int tm_mon; /* months since January, 0 to 11 */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday, 0 to 6 */
int tm_yday; /* days since January 1, 0 to 365 */
int tm_isdst; /* Daylight Savings Time flag */
union { /* ABI-required extra fields, in a variety of types */
struct {
int __extra_1, __extra_2;
};
struct {
long __extra_1_long, __extra_2_long;
};
struct {
char *__extra_1_cptr, *__extra_2_cptr;
};
struct {
void *__extra_1_vptr, *__extra_2_vptr;
};
};
};
疑问是 我只知道 结构体中的年月日,时分秒,而tm_wday,tm_yday,tm_isdst这三个参数是不知道的,请教应该如何处理才能把UTC时间转unix时间戳。
|