From 6e0f054884987124e54527b275c3aed9e5dd83a8 Mon Sep 17 00:00:00 2001 From: Luc Date: Sat, 30 Sep 2017 21:44:35 +0800 Subject: [PATCH] use localtime_r instead of gmtime to get timezone on fatfs --- components/fatfs/src/diskio.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/components/fatfs/src/diskio.c b/components/fatfs/src/diskio.c index 7ccc1379f1..b9bc4cc417 100644 --- a/components/fatfs/src/diskio.c +++ b/components/fatfs/src/diskio.c @@ -80,12 +80,13 @@ DRESULT ff_disk_ioctl (BYTE pdrv, BYTE cmd, void* buff) DWORD get_fattime(void) { time_t t = time(NULL); - struct tm *tmr = gmtime(&t); - int year = tmr->tm_year < 80 ? 0 : tmr->tm_year - 80; + struct tm tmr; + localtime_r(&t, &tmr); + int year = tmr.tm_year < 80 ? 0 : tmr.tm_year - 80; return ((DWORD)(year) << 25) - | ((DWORD)(tmr->tm_mon + 1) << 21) - | ((DWORD)tmr->tm_mday << 16) - | (WORD)(tmr->tm_hour << 11) - | (WORD)(tmr->tm_min << 5) - | (WORD)(tmr->tm_sec >> 1); + | ((DWORD)(tmr.tm_mon + 1) << 21) + | ((DWORD)tmr.tm_mday << 16) + | (WORD)(tmr.tm_hour << 11) + | (WORD)(tmr.tm_min << 5) + | (WORD)(tmr.tm_sec >> 1); }