kopia lustrzana https://github.com/micropython/micropython
esp32/fatfs_port: Implement get_fattime so FAT files have a timestamp.
Fixes issue #3859.pull/3944/head
rodzic
d11fb09333
commit
cf1509c911
|
@ -26,20 +26,15 @@
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "py/obj.h"
|
#include <sys/time.h>
|
||||||
#include "lib/oofatfs/ff.h"
|
#include "lib/oofatfs/ff.h"
|
||||||
#include "timeutils.h"
|
#include "timeutils.h"
|
||||||
//#include "modmachine.h"
|
|
||||||
|
|
||||||
DWORD get_fattime(void) {
|
DWORD get_fattime(void) {
|
||||||
|
struct timeval tv;
|
||||||
// TODO: Optimize division (there's no HW division support on ESP8266,
|
gettimeofday(&tv, NULL);
|
||||||
// so it's expensive).
|
|
||||||
//uint32_t secs = (uint32_t)(pyb_rtc_get_us_since_2000() / 1000000);
|
|
||||||
uint32_t secs = 0;
|
|
||||||
|
|
||||||
timeutils_struct_time_t tm;
|
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) |
|
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));
|
((DWORD)tm.tm_hour << 11) | ((DWORD)tm.tm_min << 5) | ((DWORD)tm.tm_sec >> 1));
|
||||||
|
|
Ładowanie…
Reference in New Issue