Files

74 lines
2.7 KiB
C

/**
******************************************************************************
* @file date_calc.h
* @author AMG Energy Solution Team
* @version V1.0.0
* @date 07-Feb-2022
* @brief This file provides all the header of the calculation datetime.
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2022 AMG</center></h2>
******************************************************************************
*/
/** @addtogroup mBMS2
* @{
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef _DATE_CALC_H_
#define _DATE_CALC_H_
/* Includes ------------------------------------------------------------------*/
#include "hc32_ddl.h"
/* Exported types ------------------------------------------------------------*/
typedef struct _TDateTimePacket
{
uint16_t year;
uint16_t month;
uint16_t date;
uint16_t hour;
uint16_t min;
uint16_t sec;
} TDateTimePacket, *PDateTimePacket;
/* Exported constants --------------------------------------------------------*/
#define GMT_ZONE 0
#define KOREA_ZONE 1
#define UTC_TIMESTAMP 719163 // 1970-01-01
#define UTC_YEAR 1970 // 1970-01-01
#define UTC_KOREA (uint32_t)9 * 60 * 60
#define UTC_CHINA (uint32_t)9 * 60 * 60
//Epoch time offset (1 January 2000 00:00:00) = 946684800
#define UTC_EPOCH_TIME_OFFSET 946684800
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
uint32_t CalcOneYearToDay(uint16_t Year);
uint8_t CheckLeapYear(uint16_t Year);
void CalcTimeStampToDateTime(uint32_t TimeStamp, void *datetime);
uint32_t CalcDay(uint32_t iYear, uint32_t iMonth, uint32_t iDay);
uint32_t DateStampToTimeStamp(uint32_t DateStamp, uint8_t Zone);
void CalcDateStampToDateTime(uint32_t DateStamp, uint8_t *DateTime);
uint32_t DateStrToDateStamp(uint8_t *DateTime);
//extern void CalcTimeStampToDateTime1(uint32_t TimeStamp, uint8_t *DateTime);
uint32_t DateTimeToTimeStamp(PDateTimePacket adate);
uint32_t DateTimeStrToTimeStamp(uint8_t *DateTime);
#endif
/*******************(C)COPYRIGHT 2022 AMG ********************END OF FILE******/