由于工作需要,经常需要把当前时间转换成UTC格式,每次都是去如下链接查询,比较麻烦,故想着用C嵌入式代码将此实现。
Unix Time Stamp - Epoch Converter
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
/**
* @brief CALENDAR_Time calendar time structure definition
*/
typedef struct _calendar_time
{
uint8_t sec; /**< Specifies the Calendar time seconds.
This parameter must be a number between min_value = 0 and max_value = 59. */
uint8_t min; /**< Specifies the Calendar time minutes.
This parameter must be a number between min_value = 0 and max_value = 59. */
uint8_t hour; /**< Specifies the Calendar time hour.