aboutsummaryrefslogtreecommitdiff
path: root/extmod/vfs_fat.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2020-09-14 12:15:03 +1000
committerDamien George <damien@micropython.org>2020-09-18 17:20:34 +1000
commit8f20cdc353a9d1c1e5d43484b58e1eaf81ec52e0 (patch)
tree5889824fb3b3aec00d69e63220b3ad9e0ef77dda /extmod/vfs_fat.c
parentbd7af6151d605d3fc8f70cb9ddf45b2fd7881f08 (diff)
all: Rename absolute time-based functions to include "epoch".
For time-based functions that work with absolute time there is the need for an Epoch, to set the zero-point at which the absolute time starts counting. Such functions include time.time() and filesystem stat return values. And different ports may use a different Epoch. To make it clearer what functions use the Epoch (whatever it may be), and make the ports more consistent with their use of the Epoch, this commit renames all Epoch related functions to include the word "epoch" in their name (and remove references to "2000"). Along with this rename, the following things have changed: - mp_hal_time_ns() is now specified to return the number of nanoseconds since the Epoch, rather than since 1970 (but since this is an internal function it doesn't change anything for the user). - littlefs timestamps on the esp8266 have been fixed (they were previously off by 30 years in nanoseconds). Otherwise, there is no functional change made by this commit. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/vfs_fat.c')
-rw-r--r--extmod/vfs_fat.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c
index ace5ba5b6..95b7ad994 100644
--- a/extmod/vfs_fat.c
+++ b/extmod/vfs_fat.c
@@ -311,7 +311,7 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
} else {
mode |= MP_S_IFREG;
}
- mp_int_t seconds = timeutils_seconds_since_2000(
+ mp_int_t seconds = timeutils_seconds_since_epoch(
1980 + ((fno.fdate >> 9) & 0x7f),
(fno.fdate >> 5) & 0x0f,
fno.fdate & 0x1f,
@@ -319,9 +319,6 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
(fno.ftime >> 5) & 0x3f,
2 * (fno.ftime & 0x1f)
);
- #if MICROPY_EPOCH_IS_1970
- seconds += TIMEUTILS_SECONDS_1970_TO_2000;
- #endif
t->items[0] = MP_OBJ_NEW_SMALL_INT(mode); // st_mode
t->items[1] = MP_OBJ_NEW_SMALL_INT(0); // st_ino
t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // st_dev