get_fattime

The get_fattime function is called to get the current time.

DWORD get_fattime (void);

Return Value

Currnet local time shall be returned as bit-fields packed into a DWORD value. The bit fields are as follows:

bit31:25
Year origin from the 1980 (0..127, e.g. 37 for 2017)
bit24:21
Month (1..12)
bit20:16
Day of the month (1..31)
bit15:11
Hour (0..23)
bit10:5
Minute (0..59)
bit4:0
Second / 2 (0..29, e.g. 25 for 50)

Description

The get_fattime function shall return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid timestamp.

QuickInfo

This function is not needed when FF_FS_READONLY == 1 or FF_FS_NORTC == 1.

Example

DWORD get_fattime (void)
{
    time_t t;
    struct tm *stm;


    t = time(0);
    stm = localtime(&t);

    return (DWORD)(stm->tm_year - 80) << 25 |
           (DWORD)(stm->tm_mon + 1) << 21 |
           (DWORD)stm->tm_mday << 16 |
           (DWORD)stm->tm_hour << 11 |
           (DWORD)stm->tm_min << 5 |
           (DWORD)stm->tm_sec >> 1;
}

Return