Skip to content

Commit 46b366d

Browse files
committed
alif/fatfs_port: Implement get_fattime.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 0feb4f5 commit 46b366d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

ports/alif/fatfs_port.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@
2424
* THE SOFTWARE.
2525
*/
2626

27+
#include "py/mphal.h"
28+
#include "shared/timeutils/timeutils.h"
2729
#include "lib/oofatfs/ff.h"
2830

2931
DWORD get_fattime(void) {
30-
// TODO
31-
int year = 2024;
32-
int month = 1;
33-
int day = 1;
34-
int hour = 0;
35-
int min = 0;
36-
int sec = 0;
37-
return ((year - 1980) << 25) | (month << 21) | (day << 16) | (hour << 11) | (min << 5) | (sec / 2);
32+
timeutils_struct_time_t tm;
33+
timeutils_seconds_since_epoch_to_struct_time(mp_hal_time_get(NULL), &tm);
34+
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);
3835
}

0 commit comments

Comments
 (0)