📄 datetotimeconversion.c
字号:
/*
* File : DateToTimeConversion
*
* Description : This file contains definition of MkTime function
*
* Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED.
*
* This file contains unpublished confidential and proprietary information
* of ZiLOG, Inc.
* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED
* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
* This is not a license and no use of any kind of this work is authorized
* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's
* sole discretion
*/
#include "ZClock.h"
#include "ZTypes.h"
/* Function : MkTime
*
* Description : This function returns the seconds for the particular
* Date and time that has specified.
*
* Inputs : year - Specifies the year.
* mon - Specifies the month.
* day - Specifies the day.
* hour - Specifies the hour.
* min - Specifies the minutes.
* sec - Specifies the seconds.
*
* Outputs : returns the seconds for the above mentioned Date and Time.
*
*
* Dependencies : None.
*/
UINT32 MkTime(UINT year, UINT mon,UINT day, UINT16 hour,UINT16 min, UINT16 sec)
{
if (0 >= (INT) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */
mon += 12; /* Puts Feb last since it has leap day */
year -= 1;
}
{
UINT temp4 = year/4;
UINT temp100 = year/100;
UINT temp400 = year/400;
UINT tempmon = (367 * mon/12);
UINT32 temp365 = (UINT32)year * (UINT32)365;
UINT32 yeartemp = (UINT32)(temp4 - temp100 + temp400 + tempmon + day) + temp365 - 719499;
UINT32 returntemp = ((yeartemp*24 + hour)*60 + min)*60 + sec;
return (returntemp); /* finally seconds */
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -