times times times

This commit is contained in:
iceman1001 2019-04-13 03:01:31 +02:00
commit dae0016bb2
3 changed files with 35 additions and 20 deletions

View file

@ -6,8 +6,8 @@
//-----------------------------------------------------------------------------
// Low frequency T55xx commands
//-----------------------------------------------------------------------------
/* Ensure localtime_r is available even with -std=c99; must be included before
*/
// ensure localtime_r is available even with -std=c99; must be included before
#if !defined(_WIN32)
#define _POSIX_C_SOURCE 200112L
#endif
@ -1205,10 +1205,15 @@ static int CmdT55xxReadTrace(const char *Cmd) {
si += 5;
data.dw = PackBits(si, 15, DemodBuffer);
struct tm *tm = NULL;
time_t now = time(NULL);
localtime_r(&now, tm);
if (data.year > tm->tm_year - 110)
struct tm *ct, tm_buf;
time_t now = time(NULL);
#if defined(_WIN32)
ct = localtime_s(&tm_buf, &now) == 0 ? &tm_buf : NULL;
#else
ct = localtime_r(&now, &tm_buf);
#endif
if (data.year > ct->tm_year - 110)
data.year += 2000;
else
data.year += 2010;