circuitpython/ports/unix/fatfs_port.c
Damien George 92899354d9 unix/fatfs_port: Implement get_fattime.
Signed-off-by: Damien George <damien@micropython.org>
2020-08-22 14:45:57 +10:00

14 lines
348 B
C

#include <time.h>
#include "lib/oofatfs/ff.h"
DWORD get_fattime(void) {
time_t now = time(NULL);
struct tm *tm = localtime(&now);
return ((1900 + tm->tm_year - 1980) << 25)
| (tm->tm_mon << 21)
| (tm->tm_mday << 16)
| (tm->tm_hour << 11)
| (tm->tm_min << 5)
| (tm->tm_sec / 2);
}