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

Fix parsing of field-separated birthdate strings with 4-digit year

... which is the format expected/required when entering or editing birthdates
in the terminal server. So this is a pretty embarassingly bad bug introduced
just before the v3.20b release to fix a less-severe bug with ecWeb new user
registration (still) writing 2-digit years to the user.birthdate field. :-(

Fix for issue #863

I considerd making these get_birthdate field functions more tolerant of less
strictly formatted strings (e.g. single-digit month or day), but decided to
keep this change to just a fix for the issue at hand. These functions could be
more robust to handle more variance in user/script input.
parent a35294c1
No related branches found
No related tags found
No related merge requests found
......@@ -906,19 +906,22 @@ int getbirthyear(scfg_t* cfg, const char* birth)
+ DECVAL(birth[1], 100)
+ DECVAL(birth[2], 10)
+ DECVAL(birth[3], 1);
// DD/MM/YY or MM/DD/YY format
// DD/MM/[CC]YY or [CC]MM/DD/YY format
time_t now = time(NULL);
struct tm tm;
if (localtime_r(&now, &tm) == NULL)
return 0;
tm.tm_year += 1900;
int year = 1900;
int year;
if (cfg->sys_date_fmt == YYMMDD)
year += DECVAL(birth[0], 10) + DECVAL(birth[1], 1);
year = strtoul(birth, NULL, 10);
else // MMDDYY or DDMMYY
year += DECVAL(birth[6], 10) + DECVAL(birth[7], 1);
year = strtoul(birth + 6, NULL, 10);
if (year < 100) {
year += 1900;
if (tm.tm_year - year > 105)
year += 100;
}
return year;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment