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

Bug 365262

Summary: cannot create timestamp("MMdd") = "0229" after the 29th of each month
Product: z_Archived Reporter: Tom B <tmbarans>
Component: EDTAssignee: Huang Ji Yong <hjiyong>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: hjiyong
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Fix lasher: iplog+

Description Tom B CLA 2011-11-30 22:24:14 EST
Build Identifier: Eclipse 20110916-0149   EDT 0.7.0.v201111290902

You cannot create a february 29 timestamp e.g. myTimestamp timestamp("MMdd") = "0229" if you are running the program after the 29th of each month. An exception is thrown with the message "uncaught exception: [type=eglx.lang.TypeCastException, message=[CRRUI2017E] The value "0229" of type string cannot be converted to type timestamp]"

If you run the program before the 29th of each month, the timestamp will be created successfully. This error only occurs for Javascript generation. 



Reproducible: Always

Steps to Reproduce:
1. Set Windows clock to the 30th or 31st of the month
2. Generate EDate007.egl to javascript
3. Run the generated egl rui file in a browser. You will see the message "uncaught exception: [type=eglx.lang.TypeCastException, message=[CRRUI2017E] The value "0229" of type string cannot be converted to type timestamp]"

this error does not occur for Java generation
Comment 1 Tom B CLA 2011-11-30 22:25:58 EST
I spoke with Jing about this and she said:

"After debugging it, I found it's because the way we parse the timestamp

in javascript runtime code inside egl\jsrt\BaseTypesAndRuntimes.js

search for egl.processToken function, go to line 542 you will see the logic is comparing the day value, if it's > 29, then the month can't be 02, if day is 31, month can't be 04....

			var d = result.getDate();
			if ( (d > 29 && sub === "02")
				|| (d === 31 && (sub === "04" || sub === "06" || sub === "09" || sub === "11")) )
			{
				return null;
			}
today for me here is Nov. 30th, so d = 30, but sub = 02, therefore, it became null.  and if you or I run this test tomorrow (12/1), I think it will be successful. 
For PengFei, I bet the d = 28 or 29 when he tested the GM candidate on Monday, so it was successful 

In any case, this seems to be a bug in the processToken method, which only happens on certain day of the month. so it's not a regression."
Comment 2 Huang Ji Yong CLA 2011-12-13 02:45:21 EST
Created attachment 208302 [details]
Fix
Comment 3 Huang Ji Yong CLA 2011-12-13 02:49:46 EST
The reason is described at comment 1. Additionally reason is that there is a portion of code in egl.stringToTimeStampInternal to determine if the input string is a valid date. If the input string only contains part of the timestamp sections (e.g. only have month, date string), it will fill other part of date with the current date information. Thus, the behavior is varies when date changes.
This fix add a default year, month, date if they are not specified when doing the validation.
Comment 4 Lisa Lasher CLA 2012-04-04 22:47:37 EDT
closing this bug