Skip to content

string_to_datetime and y2k problem [CORE6495] #6725

Open
@firebird-automations

Description

@firebird-automations

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions