Syntax
short SetTime(
struct time_struct *timep
);
Parameters
- timep
- [in] Pointer to the time_struct structure.
Return value
Returns OK if the function succeeds, ERROR otherwise.
Remarks
Sets the time of the time_struct structure pointed to by timep to the real time clock.The time can be read back with the GetTime function.
Requirements
Header file:
lib.hLibrary file:
libSTARTUPOPH5000.a
Sample
#include <stdio.h>
#include "lib.h"
void main(void)
{
struct date_struct datep;
struct time_struct timep;
char mes[30];
datep.da_year = 2007;
datep.da_day = 25;
datep.da_mon = 12;
timep.ti_hour = 0;
timep.ti_min = 0;
timep.ti_sec = 0;
SetDate(&datep);
SetTime(&timep);
GetDate(&datep);
GetTime(&timep);
sprintf( mes, "date[%04d.%02d.%02d]\n",
datep.da_year, datep.da_mon, datep.da_day);
printf( mes );
sprintf( mes, "time[%02d:%02d:%02d]\n",
timep.ti_hour, timep.ti_min, timep.ti_sec);
printf( mes );
for( ;; );
}
Last updated: 2020/10/07