| author | tomb | 2012-09-13 16:43:29 (EDT) |
|---|---|---|
| committer | jihuang | 2012-09-13 16:43:29 (EDT) |
| commit | ec8ce157cf1e3dc58052201756b37a18bdfc8de0 (patch) (side-by-side diff) | |
| tree | dfda9ce3a29aa4fead6a3f997a8a43d126bb98b6 | |
| parent | 5534f13b5663378aa69108228073c85f31fc0534 (diff) | |
| download | org.eclipse.edt-ec8ce157cf1e3dc58052201756b37a18bdfc8de0.zip org.eclipse.edt-ec8ce157cf1e3dc58052201756b37a18bdfc8de0.tar.gz org.eclipse.edt-ec8ce157cf1e3dc58052201756b37a18bdfc8de0.tar.bz2 | |
Bug 372937 - Javascript 'extend' and 'timeOf' function don't work
properly with February 29 timestamps
Copy from Tom
"I have fixed these problems by using a fixed date (January 1 2000) for
the default values rather than using the current date. This fix is in
the Javascript runtime for the 'extend' and 'timeOf' functions and does
not cause any regression in the rest of the EUnit tests (for Javascript
generation). This fix is similar to one done before where the default
year was changed from current to 2000 in order to accept the date
February 29 (bug 365262)"
| -rw-r--r-- | runtimes/org.eclipse.edt.runtime.javascript/runtime/edt_runtime.js | 5 | ||||
| -rwxr-xr-x | runtimes/org.eclipse.edt.runtime.javascript/runtime/egl/jsrt/BaseTypesAndRuntimes.js | 9 |
2 files changed, 7 insertions, 7 deletions
diff --git a/runtimes/org.eclipse.edt.runtime.javascript/runtime/edt_runtime.js b/runtimes/org.eclipse.edt.runtime.javascript/runtime/edt_runtime.js index d80c318..3c0226a 100644 --- a/runtimes/org.eclipse.edt.runtime.javascript/runtime/edt_runtime.js +++ b/runtimes/org.eclipse.edt.runtime.javascript/runtime/edt_runtime.js @@ -1227,9 +1227,8 @@ egl.eglx.lang.ETimestamp.timeOf = function (ts, pattern){ // throw egl.createTypeCastException( "CRRUI2017E", [ ts, 'timestamp', 'time' ], 'time', 'timestamp' ); } var timeCopy = new Date( ts ); - var now = new Date (); - timeCopy.setDate( now.getDate() ); - timeCopy.setMonth( now.getMonth() ); + timeCopy.setDate( 1 ); //Bug 372937 changed from current date due to issues with February 29 + timeCopy.setMonth( 0 ); //Bug 372937 changed from current month due to issues with February 29 timeCopy.setFullYear( 2000 ); timeCopy.setMilliseconds( 0 ); return timeCopy; diff --git a/runtimes/org.eclipse.edt.runtime.javascript/runtime/egl/jsrt/BaseTypesAndRuntimes.js b/runtimes/org.eclipse.edt.runtime.javascript/runtime/egl/jsrt/BaseTypesAndRuntimes.js index f768d68..3580323 100755 --- a/runtimes/org.eclipse.edt.runtime.javascript/runtime/egl/jsrt/BaseTypesAndRuntimes.js +++ b/runtimes/org.eclipse.edt.runtime.javascript/runtime/egl/jsrt/BaseTypesAndRuntimes.js @@ -4189,8 +4189,8 @@ egl.dateTime.extend = function(/*type of date*/ type, /*extension*/ date, /*opti } else if ( type == "time" ) { date.setFullYear( 2000 ); - date.setMonth( now.getMonth() ); - date.setDate( now.getDate() ); + date.setMonth( 0 );//Bug 372937 changed from current month due to issues with February 29 + date.setDate( 1 ); //Bug 372937 changed from current date due to issues with February 29 date.setMilliseconds( 0 ); if (!pattern || pattern == "" ) pattern = "yyyyMMddHHmmss"; @@ -4205,9 +4205,10 @@ egl.dateTime.extend = function(/*type of date*/ type, /*extension*/ date, /*opti //second function is for pattern missing chars on the right side (zeros) var chars = [ // bug 365262, change to leap year 2000 to accept date like "0229" + //Bug 372937 changed from current month and date due to issues with February 29 [ "y", function(d){ d.setFullYear( 2000 ); }, function(d){ d.setFullYear( 0 ); } ], - [ "M", function(d){ d.setMonth( now.getMonth() ); }, function(d){ d.setMonth( 0 ); } ], - [ "d", function(d){ d.setDate( now.getDate() ); }, function(d){ d.setDate( 1 ); } ], + [ "M", function(d){ d.setMonth( 0 ); }, function(d){ d.setMonth( 0 ); } ], + [ "d", function(d){ d.setDate( 1 ); }, function(d){ d.setDate( 1 ); } ], [ "h", function(d){ d.setHours( now.getHours() ); }, function(d){ d.setHours( 0 ); } ], [ "m", function(d){ d.setMinutes( now.getMinutes() ); }, function(d){ d.setMinutes( 0 ); } ], [ "s", function(d){ d.setSeconds( now.getSeconds() ); }, function(d){ d.setSeconds( 0 ); } ], |

