diff options
author | Damien George <damien@micropython.org> | 2025-08-12 13:04:20 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-08-15 12:35:21 +1000 |
commit | 46b366d7b245360e37443ca096f120c5d601f11d (patch) | |
tree | 8800a893d036e505d1b8f74c4caa1047ce0a28c8 | |
parent | 0feb4f5ea419c038c69a6fd0b295b788c09f06a2 (diff) |
alif/fatfs_port: Implement get_fattime.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/alif/fatfs_port.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/ports/alif/fatfs_port.c b/ports/alif/fatfs_port.c index 5883c9f3b..20b7920eb 100644 --- a/ports/alif/fatfs_port.c +++ b/ports/alif/fatfs_port.c @@ -24,15 +24,12 @@ * THE SOFTWARE. */ +#include "py/mphal.h" +#include "shared/timeutils/timeutils.h" #include "lib/oofatfs/ff.h" DWORD get_fattime(void) { - // TODO - int year = 2024; - int month = 1; - int day = 1; - int hour = 0; - int min = 0; - int sec = 0; - return ((year - 1980) << 25) | (month << 21) | (day << 16) | (hour << 11) | (min << 5) | (sec / 2); + timeutils_struct_time_t tm; + timeutils_seconds_since_epoch_to_struct_time(mp_hal_time_get(NULL), &tm); + return ((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); } |