當(dāng)前位置:
首頁(yè) >
DSP学习 -- GPS时间校准电脑系统时间
發(fā)布時(shí)間:2025/3/15
31
豆豆
生活随笔
收集整理的這篇文章主要介紹了
DSP学习 -- GPS时间校准电脑系统时间
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
一、格林威治時(shí)間轉(zhuǎn)北京時(shí)間
GPS時(shí)間為格林威治時(shí)間,而 北京時(shí)間=GMT時(shí)間+8小時(shí)。
兩者轉(zhuǎn)換的算法:
參看:C語(yǔ)言實(shí)現(xiàn)格林威治時(shí)間轉(zhuǎn)北京時(shí)間
參看:STM32開發(fā) – UTC、UNIX時(shí)間戳、北京時(shí)間之間的轉(zhuǎn)換
日期數(shù)據(jù)結(jié)構(gòu)定義:
typedef struct {uint16_t year;uint8_t month;uint8_t day;uint8_t hour;uint8_t minute;uint8_t second; }time_t;轉(zhuǎn)換實(shí)現(xiàn):
void UTCToBeijing(time_t* time) {uint8_t days = 0;if (time->month == 1 || time->month == 3 || time->month == 5 || time->month == 7 || time->month == 8 || time->month == 10 || time->month == 12){days = 31;}else if (time->month == 4 || time->month == 6 || time->month == 9 || time->month == 11){days = 30;}else if (time->month == 2){if ((time->year % 400 == 0) || ((time->year % 4 == 0) && (time->year % 100 != 0))) /* 判斷平年還是閏年 */{days = 29;}else{days = 28;}}time->hour += 8; /* 北京時(shí)間比格林威治時(shí)間快8小時(shí) */if (time->hour >= 24) /* 跨天 */{time->hour -= 24;time->day++;if (time->day > days) /* 跨月 */{time->day = 1;time->month++;if (time->month > 12) /* 跨年 */{time->year++;}}} }二、設(shè)置系統(tǒng)時(shí)間
使用 date time這兩個(gè)DOC指令
例如:
三、Visual Studio編譯生成的應(yīng)用以管理員身份運(yùn)行配置
如果需要以管理員身份運(yùn)行,需要如下配置:
屬性->鏈接器->清單文件->UAC執(zhí)行級(jí)別
選擇 requireAdministrator (/level=‘requireAdministrator’)
總結(jié)
以上是生活随笔為你收集整理的DSP学习 -- GPS时间校准电脑系统时间的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 产品经理最痛苦的事情
- 下一篇: 操作系统(一)操作系统的概念、功能