summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2018-08-26 22:22:45 -0700
committerGitHub <noreply@github.com>2018-08-26 22:22:45 -0700
commit569a050e82fc40c7d56caa6ca76eed94fa244bc8 (patch)
tree6a607711727074bbc5b90a25fab8df4db2df9210 /ports
parent9a10849afdab9e610dfeab58cb03292bac9ca997 (diff)
parentb61cf8d81f6f5c59175de9e7508752b0f27d7fcd (diff)
Merge pull request #1143 from notro/stat_epoch_fix
Fix os.stat() epoch and use RTC for file timestamp
Diffstat (limited to 'ports')
-rw-r--r--ports/atmel-samd/fatfs_port.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ports/atmel-samd/fatfs_port.c b/ports/atmel-samd/fatfs_port.c
index e1eba350a..67c6c9d35 100644
--- a/ports/atmel-samd/fatfs_port.c
+++ b/ports/atmel-samd/fatfs_port.c
@@ -28,8 +28,13 @@
#include "py/runtime.h"
#include "lib/oofatfs/ff.h" /* FatFs lower layer API */
#include "lib/oofatfs/diskio.h" /* FatFs lower layer API */
+#include "lib/timeutils/timeutils.h"
+#include "shared-bindings/rtc/RTC.h"
DWORD get_fattime(void) {
- // TODO(tannewt): Support the RTC.
- return ((2016 - 1980) << 25) | ((9) << 21) | ((1) << 16) | ((16) << 11) | ((43) << 5) | (35 / 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);
}