diff options
author | Damien George <damien@micropython.org> | 2020-07-29 01:01:31 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-08-22 14:45:57 +1000 |
commit | 92899354d96a5b5463f3002b2476a73c11ebe626 (patch) | |
tree | 8d80cc9bc019c750512479caf4f77c272a161709 | |
parent | 55c76eaac12af4e93f8de11bb25c835e8b65c623 (diff) |
unix/fatfs_port: Implement get_fattime.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/unix/fatfs_port.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ports/unix/fatfs_port.c b/ports/unix/fatfs_port.c index 30f1959f5..4ec5b919a 100644 --- a/ports/unix/fatfs_port.c +++ b/ports/unix/fatfs_port.c @@ -1,5 +1,13 @@ +#include <time.h> #include "lib/oofatfs/ff.h" DWORD get_fattime(void) { - return 0; + 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); } |