Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363363

Summary: String-to-date conversion treats Feb 29 as March 1
Product: z_Archived Reporter: Matt Heitz <mheitz>
Component: EDTAssignee: Matt Heitz <mheitz>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Matt Heitz CLA 2011-11-09 13:13:42 EST
When we convert a string containing February 29th to a date, it "rolls forward" to March 1st.

Here's a testcase.  The first assignment works fine.  The second turns Feb 29 into March 1.  The third does the same thing, even though 2011 isn't a leap year.

handler TestRUI type RUIHandler { onConstructionFunction = start }
	function start()
		d date;

		d = "02/28/2012";
		SysLib.writeStdout( d );

		d = "02/29/2012";
		SysLib.writeStdout( d );

		d = "02/29/2011";
		SysLib.writeStdout( d );
	end
end
Comment 1 Matt Heitz CLA 2011-11-09 13:29:14 EST
Fixed with changes to the runtime (egl.processFunction and helper functions).  We now add a property to the Date object to keep track of when we've seen Feb 29.  Once we're done parsing, if the flag is set we make sure the year is a leap year and then reset the date to Feb 29 because it may have rolled forward.

The testcase now correctly assigns 02/29/2012 in the second assignment.  The third assignment now correctly throws an exception (because 2011 isn't a leap year, so it doesn't have a Feb 29).
Comment 2 Matt Heitz CLA 2011-11-09 13:29:53 EST
Closing.