Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363363 - String-to-date conversion treats Feb 29 as March 1
Summary: String-to-date conversion treats Feb 29 as March 1
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Matt Heitz CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-09 13:13 EST by Matt Heitz CLA
Modified: 2017-02-23 14:18 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.