📄 pc_udate.c
字号:
/************************************************************************
*
* Copyright (c) 2002 by Accelerated Technology, Inc.
*
* PROPRIETARY RIGHTS of Accelerated Technology are involved in
* the subject matter of this material. All manufacturing,
* reproduction, use, and sales rights pertaining to this subject
* matter are governed by the license agreement. The recipient of
* this software implicitly accepts the terms of the license.
*
*
*************************************************************************
* FILE NAME VERSION
*
* PC_UPDATE.C FILE 2.3.2
*
* COMPONENT
*
* Nucleus File
*
* DESCRIPTION
*
* When the system needs to date stamp a file it will call this
* routine to get the current time and date. YOU must modify the
* shipped routine to support your hardware's time and date
* routines. If you don't modify this routine the file date on all
* files will be the same.
*
* The source for this routine is in file pc_udate.c and is self
* explanatory.
*
* DATA STRUCTURES
*
* None.
*
* FUNCTIONS
*
* pc_getsysdate Get date and time from the
* host system.
*
* DEPENDENCIES
*
* pcdisk.h File common definitions
*
* NOTE: This module is linked in with File.lib. After you make *
* changes, you must rebuild File.lib. *
*******************************************************************/
#include "file\pcdisk.h"
#if (X86)
#define RTC_ADDR 0x0070
#define RTC_DATA 0x0071
int inp(unsigned portid);
int inport(int portid);
UINT16 convert_bios(UINT16 value)
{
UINT16 temp;
if (value > 10)
{
temp = value/0x10;
value = (UINT16)value - (6 * temp);
}
return(value);
}
#endif
/************************************************************************
* FUNCTION
*
* pc_getsysdate
*
* DESCRIPTION
*
* Get date and time from the host system.
*
* AUTHOR
*
* Kyoichiro Toda
*
* INPUTS
*
* pd Date stamping buffer.
*
* OUTPUTS
*
* Pointer of the buffer of date structure.
*
*************************************************************************/
DATESTR *pc_getsysdate(DATESTR *pd)
{
UINT16 year; /* relative to 1980 */
UINT16 month; /* 1 - 12 */
UINT16 day; /* 1 - 31 */
UINT16 hour;
UINT16 minute;
UINT16 sec; /* Note: seconds are 2 second/per. ie 3 == 6 seconds */
UINT8 cenmsec;
/* This code will work if yoiu have ANSI time functions. otherwise get
rid of it and look below where the time is wired to 3/28/8. you may modify
that code to work in your environment. */
#include <time.h>
struct tm *timeptr;
time_t timer;
time(&timer);
timeptr = localtime(&timer);
hour = (UINT16) timeptr->tm_hour;
minute = (UINT16) timeptr->tm_min;
sec = (UINT16) (timeptr->tm_sec/2);
/* Date comes back relative to 1900 (eg 93). The pc wants it relative to
1980. so subtract 80 */
year = (UINT16) (timeptr->tm_year-80);
month = (UINT16) (timeptr->tm_mon+1);
day = (UINT16) timeptr->tm_mday;
cenmsec = 0; /* 0 - 99 */
/* This code is useless but very generic */
/* Hardwire for now */
/* 7:37:28 PM */
hour = 19;
minute = 37;
sec = 14;
/* 3-28-88 */
year = 8; /* relative to 1980 */
month = 3; /* 1 - 12 */
day = 28; /* 1 - 31 */
cenmsec = 0; /* 0 - 99 */
pd->cmsec = cenmsec;
pd->time = (UINT16) ( (hour << 11) | (minute << 5) | sec );
pd->date = (UINT16) ( (year << 9) | (month << 5) | day );
return(pd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -