UTC时间转换为北京时间
时间类型结构体
//UTC时间信息
__packed typedef struct
{ uint16_t year; //年份uint8_t month; //月份uint8_t date; //日期uint8_t hour; //小时uint8_t min; //分钟uint8_t sec; //秒钟
}nmea_time;
UTC时间转任意时区时间
void UTC_to_BJtime(nmea_time* utc_time, int8_t timezone)
{int year,month,day,hour;int lastday = 0; //last day of this monthint lastlastday = 0; //last day of last monthyear = utc_time->year; //utc timemonth = utc_time->month;day = utc_time->date;hour = utc_time->hour + timezone; if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12){lastday = 31;if(month == 3){if((year%400 == 0)||(year%4 == 0 && year%100 != 0)) //if this is lunar yearlastlastday = 29;elselastlastday = 28;}if(month == 8)lastlastday = 31;}else if(month == 4 || month == 6 || month == 9 || month == 11){lastday = 30;lastlastday = 31;}else{lastlastday = 31;if((year%400 == 0)||(year%4 == 0 && year%100 != 0))lastday = 29;elselastday = 28;}if(hour >= 24){ // if >24, day+1hour -= 24;day += 1; if(day > lastday){ // next month, day-lastday of this monthday -= lastday;month += 1;if(month > 12){ // next year , month-12month -= 12;year += 1;}}}if(hour < 0){ // if <0, day-1hour += 24;day -= 1; if(day < 1){ // month-1, day=last day of last monthday = lastlastday;month -= 1;if(month < 1){ // last year , month=12month = 12;year -= 1;}}}// transfer value to NMEA_result.local_timeNMEA_result.local_time.year = year;NMEA_result.local_time.month = month;NMEA_result.local_time.date = day;NMEA_result.local_time.hour = hour;NMEA_result.local_time.min = utc_time->min;NMEA_result.local_time.sec = utc_time->sec;
}
UTC时间转换为北京时间相关推荐
- QT UTC(T和Z格式)时间转换为北京时间
一.UTC 协调世界时,又称世界统一时间.世界标准时间.国际协调时间.由于英文(CUT)和法文(TUC)的缩写不同,作为妥协,简称UTC.和北京时间相差八小时. 二.将获取的UTC字符串转换为北京时间 ...
- 【C语言】UTC时间转换为北京时间
最近使用GPS模块获取解析GPRMC数据的时候,获取到的是UTC时间,需要转换为北京时间,网上看了一些文章,发现存在一些问题,于是自己完善了一下,并做了注释,方便理解. typedef struct ...
- 东八区转为0时区_格林尼治时间转换为北京时间
展开全部 格林尼治时间=北京时间-8小时. "格林尼治".英国大伦敦的一32313133353236313431303231363533e4b893e5b19e3133343365 ...
- JavaScript把客户端时间转换为北京时间
写在前面 写了一遍又一遍,网页老卡住,没保存下来,不写了. 时间转换代码 //获得北京时间Date.prototype.getBJDate = function () {//获得当前运行环境时间var ...
- 将格林威治时间转换为北京时间
Date nowTime = new Date(); // 要转换的时间Calendar cal = Calendar.getInstance();cal.setTimeInMillis(nowTim ...
- php求北京时间方法,php怎么将获得的时间转换为北京时间
从php5.10开始,php中加入了时区的设置,在php中显示的时间都是格林威治标准时间,这就造成了我们中国的用户会差八个小时的问题! 相关设置是修改php.ini中的 date.timezone 参 ...
- 物联网设备获取北京时间、年月日、星期几,GMT格林威治标准时间转换为北京时间,授时api Fiddler抓包调试
1. 获取北京时间.年月日 授时api 苏宁获取北京时间的api不要太方便:http://quan.suning.com/getSysTime.do 使用 Fiddler抓包调试,查看HTTP返回报文 ...
- JavaScript把世界各地客户端时间转为北京时间,并取得时间戳
1.把客户端时间转换为北京时间 function getBeijingtime() {//获得当前运行环境时间var d = new Date();currentDate = new Date();t ...
- c语言 北京时间转换utc时间_utc时间如何转换为北京时间
整个地球分为二十四时区,每个时区都有自己的本地时间.在国际无线电通信场合,为了统一起见,使用一个统一的时间,称为通用协调时(UTC, Universal Time Coordinated).UTC与格 ...
最新文章
- 什么文件格式可以通过流来直接读取或写入
- 币安被赶走,交易所寒冬将至?
- go 安装墙外的依赖包报错问题
- Linux 金字塔 的shell命令,linux下保留文件系统下剩余指定数目文件的shell脚本
- SQLServer报表服务研究文档
- Java操作excel自动生成水印背景
- MPAndroidChart 3.0——BarChart(一)
- android闹钟报告分析,闹钟分析---分析设计报告全解.doc
- android短信接收器的实现,可以实现自动填写短信验证码功能
- 后渗透之关闭防火墙、杀毒软件并开启远程桌面
- Biotin-PEG-Mal,Biotin-PEG-Maleimide,生物素聚乙二醇马来酰亚胺的应用介绍,一起来看
- c++调用Python详解,及实例
- cocosCreator 精灵图片加载(一键还原大小+动态修改图片)
- 给20块钱买可乐,每瓶可乐3块钱,喝完之后退瓶子可以换回1块钱,问最多可以喝到多少瓶可乐?
- 源码交易网站高仿站源网
- MyEclipse weblogic Deploy Location项目名称不正确解决方案
- ACM论文投稿时如何删除页眉和reference信息
- Multi2Sim 5.0安装
- EPS创建三维模型-(osgb数据在EPS中的转换数据)
- 018 cisco 3560 MAC地址绑定
热门文章
- flink的Standalone-HA模式安装
- js监听页面焦点事件
- java unicode to 中文_java 怎么把unicode转中文
- 7寸安卓通用车载导航
- [2022-kaggle]-Novozymes Enzyme Stability Prediction前排高分baseline(Novozymes 酶稳定性预测)
- 健康专家洪昭光谈生活方式与身心健康(五) —— 健康第一大基石(合理膳食)
- 优先队列练习 黑匣子
- IDEA插件系列(65):NeckProtector插件——定时提醒休息
- SpringMVC教程(三)
- matlab基于遗传算法的多目标优化算法(附代码获取方法)