Merge pull request #2367 from iot49/mtime

fix mtime on file creation
This commit is contained in:
Dan Halbert 2020-01-07 17:19:40 -05:00 committed by GitHub
commit 8d629a957d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,8 +26,17 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "lib/oofatfs/ff.h" #include "lib/oofatfs/ff.h"
#include "lib/timeutils/timeutils.h"
#include "shared-bindings/rtc/RTC.h"
#include "shared-bindings/time/__init__.h"
DWORD get_fattime(void) { DWORD get_fattime(void) {
// TODO: Implement this function. For now, fake it. #if CIRCUITPY_RTC
return ((2016 - 1980) << 25) | ((12) << 21) | ((4) << 16) | ((00) << 11) | ((18) << 5) | (23 / 2); timeutils_struct_time_t tm;
common_hal_rtc_get_time(&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 >> 1);
#else
return ((2016 - 1980) << 25) | ((9) << 21) | ((1) << 16) | ((16) << 11) | ((43) << 5) | (35 / 2);
#endif
} }