原始版本

This commit is contained in:
冯佳
2025-06-19 21:56:46 +08:00
parent fe98e5f010
commit a4841450cf
4152 changed files with 1910684 additions and 0 deletions

View File

@ -0,0 +1,31 @@
#include <sys/time.h>
#include <rtthread.h>
/**
* @brief 测试 timegm 函数,将指定时间转换为时间戳
*
* 需要注意 tm 结构体的各字段含义:
* tm_year: 年份 = 实际年份 - 1900
* tm_mon : 月份 = 0~111月为0
* tm_mday: 日
* tm_hour: 时
* tm_min : 分
* tm_sec : 秒
* tm_isdst: 夏令时标志0表示不使用夏令时
*/
void test_timegm(void)
{
struct tm tm = {0};
time_t timestamp;
tm.tm_year = 2025 - 1900; // 年份从1900开始
tm.tm_mon = 5 - 1; // 月份0-115月为4
tm.tm_mday = 23;
tm.tm_hour = 9;
tm.tm_min = 56;
tm.tm_sec = 50;
tm.tm_isdst = 0; // 不使用夏令时
timestamp = mktime(&tm);
//rt_kprintf("时间戳: %ld\n", (long)timestamp);
}
MSH_CMD_EXPORT(test_timegm, test timegm function);