Skip to content
Snippets Groups Projects
Commit 354d296a authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

unixtodstr() will output "00/00/00" on invalid dates instead of "01/00/00"

"01/00/00" would get parsed/converted back to Jan-1-2000 (usually), which is
usually not what we want.
parent 510fee8b
No related branches found
No related tags found
No related merge requests found
...@@ -122,25 +122,26 @@ char* unixtodstr(scfg_t* cfg, time32_t t, char *str) ...@@ -122,25 +122,26 @@ char* unixtodstr(scfg_t* cfg, time32_t t, char *str)
} }
if(tm.tm_mday>31) if(tm.tm_mday>31)
tm.tm_mday=1; tm.tm_mday=1;
++tm.tm_mon;
} }
} }
if (cfg->sys_date_fmt == YYMMDD) if (cfg->sys_date_fmt == YYMMDD)
sprintf(str,"%02u%c%02u%c%02u" sprintf(str,"%02u%c%02u%c%02u"
,TM_YEAR(tm.tm_year) ,TM_YEAR(tm.tm_year)
,cfg->sys_date_sep ,cfg->sys_date_sep
,tm.tm_mon+1 ,tm.tm_mon
,cfg->sys_date_sep ,cfg->sys_date_sep
,tm.tm_mday); ,tm.tm_mday);
else if(cfg->sys_date_fmt == DDMMYY) else if(cfg->sys_date_fmt == DDMMYY)
sprintf(str,"%02u%c%02u%c%02u" sprintf(str,"%02u%c%02u%c%02u"
,tm.tm_mday ,tm.tm_mday
,cfg->sys_date_sep ,cfg->sys_date_sep
,tm.tm_mon+1 ,tm.tm_mon
,cfg->sys_date_sep ,cfg->sys_date_sep
,TM_YEAR(tm.tm_year)); ,TM_YEAR(tm.tm_year));
else else
sprintf(str,"%02u%c%02u%c%02u" sprintf(str,"%02u%c%02u%c%02u"
,tm.tm_mon+1 ,tm.tm_mon
,cfg->sys_date_sep ,cfg->sys_date_sep
,tm.tm_mday ,tm.tm_mday
,cfg->sys_date_sep ,cfg->sys_date_sep
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment