Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string_to_datetime and y2k problem [CORE6495] #6725

Open
firebird-automations opened this issue Feb 24, 2021 · 2 comments
Open

string_to_datetime and y2k problem [CORE6495] #6725

firebird-automations opened this issue Feb 24, 2021 · 2 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @ibprovider

string_to_datetime has following code for correction of y2k problem (two-digit year):

	tm times2;
	Firebird::TimeStamp::getCurrentTimeStamp\(\)\.decode\(&times2\);

	// Handle defaulting of year

	if \(description\[position\_year\] == 0\) \{
		times\.tm\_year = times2\.tm\_year \+ 1900;
	\}
	else if \(description\[position\_year\] <= 2\)
	\{
		// Handle conversion of 2\-digit years
		if \(times\.tm\_year < \(times2\.tm\_year \- 50\) % 100\)
			times\.tm\_year \+= 2000;
		else
			times\.tm\_year \+= 1900;
	\}

	times\.tm\_year \-= 1900;
	times\.tm\_mon \-= 1;

---
This code looks to the CURRENT year, but adjust the two-digit year number on 1900 or 2000.

When current year will be more than 2050, this code will return strange result.

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

Please define what you mean with "will return strange result", and why you think it is strange.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

This algorithm, if current year is 1990, is also strange.

It will make 80 be 2080, which would probably not be what one were thinking.

In the same way, we must decide how this will work when approaching 2100.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant