get_gsonsen_xyz(t);
}
+
+// 判断是否为闰年
+int isLeapYear(int year) {
+ return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
+}
+
+// 计算某年某月的天数
+int daysInMonth(int year, int month) {
+ const int days[12] = {31, 28 + isLeapYear(year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+ return days[month - 1];
+}
+
+// 计算时间距离1970年1月1日00:00:00的秒数
+uint32_t secondsSinceEpoch(int year,int month,int day,int hour,int min,int sec) {
+ const int secondsPerMinute = 60;
+ const int secondsPerHour = 3600;
+ const int secondsPerDay = 86400;
+ const int secondsPerYear = 31536000; // 不考虑闰秒
+
+ long long seconds = 0;
+
+ // 计算年份之间的秒数
+ for (int i = 1970; i < year; ++i) {
+ seconds += isLeapYear(i) ? secondsPerYear + secondsPerDay : secondsPerYear;
+ }
+
+ // 计算月份之间的秒数
+ for (int i = 1; i < month; ++i) {
+ seconds += daysInMonth(year, i) * secondsPerDay;
+ }
+
+ // 计算当月的秒数
+ seconds += (day - 1) * secondsPerDay;
+ seconds += hour * secondsPerHour;
+ seconds += min * secondsPerMinute;
+ seconds += sec;
+
+ return seconds;
+}
+
+void get_rtc(uint32_t *msc)
+{
+ char time_data[64] = {0};
+ int year,month,day,hour,min,sec;
+ uapi_get_yyyymmddhhmmss_Date(time_data);
+ PRINT("timedata : %s \r\n",time_data);
+ sscanf(time_data, "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &min, &sec);
+ *msc = secondsSinceEpoch(year,month,day,hour,min,sec);
+ PRINT("msc : %d \r\n",*msc);
+}
+
//#include "lis2doc_reg.h"
#include "stdio.h"