📄 pc_udate.c
字号:
/*
* EBS - RTFS (Real Time File Manager)
*
* Copyright Peter Van Oudenaren , 1993
* All rights reserved.
* This code may not be redistributed in source or linkable object form
* without the consent of its author.
*/
/*
*****************************************************************************
PC_GETSYSDATE - Get the current system time and date (USER SUPPLIED)
Summary
#include <pcdisk.h>
DATESTR *pc_getsysdate(pd)
DATESTR *pd; put result here
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.
NOTE: Be sure to retain the property of returning its argument. The
package depends on it.
Returns
The argument it was passed. A structure containing date and time info.
Example:
#include <pcdisk.h>
DATESTR crdate;
Load the inode copy name,ext,attr,cluster, size,datetime
pc_init_inode( pobj->finode, filename, fileext,
attr, cluster, 0L ,pc_getsysdate(&crdate) );
*****************************************************************************
*/
#include "pcdisk.h"
/* get date and time from the host system */
DATESTR *pc_getsysdate(DATESTR *pd) /*__fn__*/
{
UCOUNT year; /* relative to 1980 */
UCOUNT month; /* 1 - 12 */
UCOUNT day; /* 1 - 31 */
UCOUNT hour;
UCOUNT minute;
UCOUNT sec; /* Note: seconds are 2 second/per. ie 3 == 6 seconds */
#if(0)
/* 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 = (UCOUNT) timeptr->tm_hour;
minute = (UCOUNT) timeptr->tm_min;
sec = (UCOUNT) (timeptr->tm_sec/2);
/* Date comes back relative to 1900 (eg 93). The pc wants it relative to
1980. so subtract 80 */
year = (UCOUNT) (timeptr->tm_year-80);
month = (UCOUNT) (timeptr->tm_mon+1);
day = (UCOUNT) timeptr->tm_mday;
#else
/* 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 */
#endif
pd->time = (UCOUNT) ( (hour << 11) | (minute << 5) | sec);
pd->date = (UCOUNT) ( (year << 9) | (month << 5) | day);
return (pd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -