This function gets the file modification date and time.

Syntax

int fdatetime(
  char *filename,
  struct date_struct *datep,
  struct time_struct *timep
);

Parameters

filename
[in] Pointer to the file name for which you want to get the modification date.
datep
[out] Pointer to the date_struct structure that stores the retrieved date.
timep
[out] Pointer to the time_struct structure that stores the retrieved time.

Return value

Returns OK if the function ends normally, and ERROR if it ends abnormally.

Remarks

This API is compatible with OS version TH15J06 or later.

Requirements

Header file:
lib.h
Library file:
libSTARTUPOPH5000.a

Sample

#include <stdio.h>
#include <string.h>
#include "lib.h"

#define MAX_FNAME  13
void main(void)
{
    char f_name[MAX_FNAME];
    struct date_struct datep;
    struct time_struct timep;

    char ch;

    GotoXY( 1,1 );
    printf("Press F1 Key\n");

    while(1)
    {
        if (kbhit())
        {
            ch = getchar();
            if (ch == F1_KEY) break;
            ResetKey();
        }
    }

    memset(f_name, 0x0, sizeof(f_name));
    strcpy(f_name, "opto.hex");

    if (fdatetime(f_name, &datep, &timep) == OK)
    {
        GotoXY( 1,2 );
        printf("%s\r\n", f_name);
        printf(" %u/%u/%u,%u:%u:%u\r\n",
                datep.da_year, datep.da_mon, datep.da_day,
                timep.ti_hour, timep.ti_min, timep.ti_sec);
    }
    else
    {
        GotoXY( 1,2 );
        printf("ERROR!\r\n");
    }

    while(1)
    {
        Idle();
    }
}

Last updated: 2020/10/08