diff options
| author | Damien George | 2018-06-13 14:13:34 +1000 |
|---|---|---|
| committer | Damien George | 2018-06-13 14:13:34 +1000 |
| commit | cf1509c911a1e1f983538105592575a8a520341f (patch) | |
| tree | 3d9fd5681401ea513617e54104eed0c5abe90e4f | |
| parent | d11fb09333ab96ec1b4e9d10d74961caf1172153 (diff) | |
esp32/fatfs_port: Implement get_fattime so FAT files have a timestamp.
Fixes issue #3859.
| -rw-r--r-- | ports/esp32/fatfs_port.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/ports/esp32/fatfs_port.c b/ports/esp32/fatfs_port.c index b3690a01f..880324ed8 100644 --- a/ports/esp32/fatfs_port.c +++ b/ports/esp32/fatfs_port.c @@ -26,20 +26,15 @@ * THE SOFTWARE. */ -#include "py/obj.h" +#include <sys/time.h> #include "lib/oofatfs/ff.h" #include "timeutils.h" -//#include "modmachine.h" DWORD get_fattime(void) { - - // TODO: Optimize division (there's no HW division support on ESP8266, - // so it's expensive). - //uint32_t secs = (uint32_t)(pyb_rtc_get_us_since_2000() / 1000000); - uint32_t secs = 0; - + struct timeval tv; + gettimeofday(&tv, NULL); timeutils_struct_time_t tm; - timeutils_seconds_since_2000_to_struct_time(secs, &tm); + timeutils_seconds_since_2000_to_struct_time(tv.tv_sec, &tm); return (((DWORD)(tm.tm_year - 1980) << 25) | ((DWORD)tm.tm_mon << 21) | ((DWORD)tm.tm_mday << 16) | ((DWORD)tm.tm_hour << 11) | ((DWORD)tm.tm_min << 5) | ((DWORD)tm.tm_sec >> 1)); |
