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

Bug 361345

Summary: date's year not changed when using using addDays() to go from one year to another
Product: z_Archived Reporter: Tom B <tmbarans>
Component: EDTAssignee: Project Inbox <edt.javagen-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jeffdouglas, tmbarans
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tom B CLA 2011-10-19 03:40:11 EDT
Build Identifier: 20110218-0911

When using myDate.addDays() method, an incorrect result is returned when adding or subtracting 365 days (i.e. one year). Either the returned date is the same as the original or it is different by one day rather than one year

Reproducible: Always

Steps to Reproduce:
Generate this to Java
const marFirst1999 date = "03-01-1999";
function hello(){@Test}
		result date = marFirst1999.addDays(-365);
		Syslib.writestdout(result);
	end

Expected value = '1998-03-01' Actual value = '1999-03-01 00:00:00.000000

see EDate002.egl in org.eclipse.edt.eunit.test/api.eglx_lang
Comment 1 Tom B CLA 2011-10-21 05:47:40 EDT
CORRECTION: The problem occurs when the new date is supposed to be a different year when in fact the year does not change

e.g.

function runAssignmentFunction14(){@Test}
		myDate date = "12-31-2011";
		myDate2 date = "01-01-2012";
		actual=myDate.addDays(1);
		LogResult.assertDateEqual("addition non-leap year to non-leap year", myDate2,actual);
	end

FAILED - addition non-leap year to non-leap year - Failed: Expected value = '2012-01-01' Actual value = '2011-01-01 00:00:00.000000'
Comment 2 Jeff Douglas CLA 2011-10-21 14:55:54 EDT
fixed
Comment 3 Tom B CLA 2011-10-23 22:16:13 EDT
verified for  EGL Development Tools (EDT) 0.7.0.v201110232102
Comment 4 Lisa Lasher CLA 2011-11-09 14:06:44 EST
Closing this work item