[Laszlo-user] Date issue (convertion from string)
P T Withington
ptw at openlaszlo.org
Mon Jul 23 13:08:10 PDT 2007
On 2007-07-23, at 15:34 EDT, Jean-Baptiste BRIAUD wrote:
> That works
> 1. because of using getFullYear() with getYear() it failed
> 2. because of extra parenthesis (date_birth).getFullYear(); it
> failed with just date_birth.getFullYear();
>
> Now the question is why ?
> Is it due to Javascript interpreter embeded in Flash ?
Yes.
> If yes, we should not reproduce it in DHTML, am I right ?
Also correct. Date is fully-featured in DHTML runtime.
> This a real question for business application that are known to use
> a lot of Date.
>
> ------
> <canvas width="800" >
> <simplelayout axis="y" spacing="5"/>
> <text width="800" id="pouette"/>
> <button text="OK">
> <handler name="onclick">
> var date_birth = new Date("2005", "11", "3");
> var thisYear = (new Date()).getFullYear();
> var age = thisYear - (date_birth).getFullYear();
> pouette.setText(date_birth + " : " + thisYear + " : " + age);
> </handler>
> </button>
> </canvas>
>
> Jean-Baptiste BRIAUD wrote:
>> (new Date()).getFullYear()
>> return 2007 witch look like correct, but
>> (new Date()).getYear()
>> return 107 if there is no graphical artifact on my side witch is
>> obviously incorrect.
>>
>> Someone confirm or I'm too tired ?
>>
>> Jean-Baptiste BRIAUD wrote:
>>> I added more debug :
>>> var date_birth = new Date('1/1/2006');
>>> var thisYear = new Date().getYear();
>>> var age = thisYear - date_birth.getYear();
>>> pouette.setText(date_birth + " : " + thisYear + " : " + age);
>>>
>>> The text show -> Invalid date : undefined : NaN
>>>
>>> So, apparently, the probleme is on date_birth first,
>>> note that does not mean there is no bug on getYear() (I'll try
>>> right now).
>>>
>>>
>>> P T Withington wrote:
>>>> Looks like a bug with the SWF compiler. Please file at http://
>>>> jira.openlaszlo.org.
>>>>
>>>> As a work-around, try:
>>>>
>>>> thisYear =(new Date).getFullYear()
>>>>
>>>> which I just tested and appears to work correctly.
>>>>
>>>> On 2007-07-23, at 14:31 EDT, Jean-Baptiste BRIAUD wrote:
>>>>
>>>>> Hi the list !
>>>>>
>>>>> Any idea why that code produce NaN ?
>>>>> I'm not sure about the OL version since I tried that snipset
>>>>> online with
>>>>> http://www.openlaszlo.org/lps/laszlo-explorer/index.jsp?
>>>>> navset=nav10.xml&bookmark=Introduction
>>>>>
>>>>> When I try my full code with 4.0.2 I got this error :
>>>>> WARNING: pet-create-1.lzx:329: reference to undefined property
>>>>> 'getFullYear'
>>>>> ERROR: Compiler.substitute:-1: undefined object does not have a
>>>>> property 'make'
>>>>>
>>>>> Are there known issue with JavaScript Date Object ?
>>>>>
>>>>> --------------------------------------
>>>>> <canvas width="200" >
>>>>> <simplelayout axis="y" spacing="5"/>
>>>>> <text id="pouette"/>
>>>>> <button text="OK">
>>>>> <handler name="onclick">
>>>>> var date_birth = new Date("1/1/2006");
>>>>> var thisYear = new Date().getFullYear();
>>>>> var age = thisYear - date_birth.getFullYear();
>>>>> pouette.setText(age);
>>>>> </handler>
>>>>> </button>
>>>>> </canvas>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
More information about the Laszlo-user
mailing list