Date declaration bug

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Date declaration bug

Postby briese-it » Fri Oct 05, 2018 9:22 am

I created a form variable and want to set a specific month on the onShow event for that variable but the variable has still the original month. Changing a new date variable created on the onShow event is working fine.
Is it a bug?

Code: Select all
/**
* @type {Date}
*
* @properties={typeid:35,uuid:"A25E3416-1A34-4CC5-9C21-BBC05B9C434C",variableType:93}
*/
var dateMinus6Month = new Date();

/**
* @param {Boolean} firstShow
* @param {JSEvent} event
* @override
*
* @properties={typeid:24,uuid:"C8A32A7E-EA94-488B-A2BA-1D17D0BDE7D3"}
*/
function onShowForm(firstShow, event) {
   _super.onShowForm(firstShow, event);

   /** @type {Date} */
   var testDate = new Date();
   testDate.setMonth(testDate.getMonth()-6);

   dateMinus6Month.setMonth(dateMinus6Month.getMonth()-6);

   application.output("dateMinus6Month: " + dateMinus6Month)
   application.output("testDate: " + testDate)
}


Result:
dateMinus6Month: Fri Oct 05 2018 09:16:02 GMT+0200 (MESZ)
testDate: Thu Apr 05 2018 09:16:02 GMT+0200 (MESZ)
Michael Harms
Briese Schiffahrts GmbH & Co.KG, Germany
- Servoy 2021.3.0.3642 Running on Windows 2019 DataCenter - MSSQL2017 & PostGreSQL
User avatar
briese-it
 
Posts: 155
Joined: Mon Jun 20, 2011 1:50 pm
Location: Leer, Germany

Re: Date declaration bug

Postby kwpsd » Sat Oct 06, 2018 8:07 pm

Try initializing the date in the onShowForm() method.


Code: Select all
/**
* @type {Date}
*
* @properties={typeid:35,uuid:"A25E3416-1A34-4CC5-9C21-BBC05B9C434C",variableType:93}
*/
var dateMinus6Month = null;

/**
* @param {Boolean} firstShow
* @param {JSEvent} event
* @override
*
* @properties={typeid:24,uuid:"C8A32A7E-EA94-488B-A2BA-1D17D0BDE7D3"}
*/
function onShowForm(firstShow, event)
{
   _super.onShowForm(firstShow, event);

   /** @type {Date} */

   var today = new Date();


   var testDate = today;

   dateMinus6Month = today;


   testDate.setMonth( testDate.getMonth() - 6 );

   dateMinus6Month.setMonth( dateMinus6Month.getMonth() - 6 );


   application.output( "dateMinus6Month: " + dateMinus6Month )

   application.output( "testDate: " + testDate )
}
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 653
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: Google [Bot] and 7 guests

cron