This function sets the date.

Syntax

short SetDate(
  struct date_struct *datep
);

Parameters

datep
[in] Pointer to the date_struct structure.

Return value

Returns OK if the function succeeds, ERROR otherwise.

Remarks

Sets the date of the date_struct structure pointed to by datep to the real time clock.
The date can be read back with the GetDate function.

Requirements

Header file:
lib.h
Library 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