mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
Merge branch 'bugfix/fatfs_timezone' into 'master'
fatfs: use localtime_r instead of gmtime to get timezone See merge request !1358
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user