You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2022/03/04 19:07:52 UTC

[GitHub] [royale-asjs] Nisaba opened a new issue #1180: As3 / JS errp

Nisaba opened a new issue #1180:
URL: https://github.com/apache/royale-asjs/issues/1180


   Hello,
   
   This code crashes:
   
           public function GetDateString(pDate: Date):String {
               if (pDate == null) return "";
               return pDate.day.toString() + "/" + pDate.month.toString() + "/" + pDate.fullYear.toString() +
                   " " + pDate.hours.toString() + ":" + pDate.minutes.toString();
           }
   
   
   Here is the error in the browser console:
   Uncaught TypeError: pDate.getDay is not a function
   
   ![image](https://user-images.githubusercontent.com/34550856/156826211-0e7da710-7cd0-464b-8692-9d7dfcc761a2.png)
    


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@royale.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] joshtynjala commented on issue #1180: As3 / JS error in date properties

Posted by GitBox <gi...@apache.org>.
joshtynjala commented on issue #1180:
URL: https://github.com/apache/royale-asjs/issues/1180#issuecomment-1082309888


   The first thing I would do is figure out what type the actual value of `pDate` is at runtime (which is what I've been encouraging you to do). My guess is that it's a string, but you won't know until you check in the debugger, or possibly with `trace()`.
   
   Once you know the type, you can to figure out how to convert that value into a proper `Date`. That conversion should probably happen in your code that parses the server response. If you do it early enough, you should have an object of the correct `Date` type before it ever gets to your `GetDateString()` function.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@royale.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] joshtynjala commented on issue #1180: As3 / JS error in date properties

Posted by GitBox <gi...@apache.org>.
joshtynjala commented on issue #1180:
URL: https://github.com/apache/royale-asjs/issues/1180#issuecomment-1080946883


   @Nisaba Could it be that `pDate` is not actually an instance of the `Date` type?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@royale.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] aharui commented on issue #1180: As3 / JS error in date properties

Posted by GitBox <gi...@apache.org>.
aharui commented on issue #1180:
URL: https://github.com/apache/royale-asjs/issues/1180#issuecomment-1081449920


   The compiler is already checking the type information it has, but because the JS runtime does not do much type-checking, there is always a chance that what gets passed in at runtime is not what the type information told the compiler.
   
   The stack trace at the exception can often contain clues, so please attach it if you can.
   
   One of the most common places to lose type information is when converting a server response to AS3 objects.
   
   The compiler "could" generate runtime type-checking, but I think that would slow everything down too much.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@royale.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] joshtynjala commented on issue #1180: As3 / JS error in date properties

Posted by GitBox <gi...@apache.org>.
joshtynjala commented on issue #1180:
URL: https://github.com/apache/royale-asjs/issues/1180#issuecomment-1081115916


   > pDate is a Date type variable.
   > In the code, the calls to the GetDateString() function send Date variable.
   > Anyway, the AS3 compiler should prevent this issue, isn't it ?
   
   Yes, the compiler certainly should prevent a value that isn't a `Date` from being passed to this function. However, something is obviously going wrong, so it seems to me that it's worth checking what the actual value is at runtime in your web browser.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@royale.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] Nisaba commented on issue #1180: As3 / JS error in date properties

Posted by GitBox <gi...@apache.org>.
Nisaba commented on issue #1180:
URL: https://github.com/apache/royale-asjs/issues/1180#issuecomment-1081080442


   pDate is a Date type variable.
   As it is specified in the AS3 code.
   
   No warning in the code about that.
   In the code, the calls to the GetDateString() function send Date variable.
   
   Anyway, the AS3 compiler should prevent this issue, isn't it ?
   
   
   Thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@royale.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [royale-asjs] Nisaba commented on issue #1180: As3 / JS error in date properties

Posted by GitBox <gi...@apache.org>.
Nisaba commented on issue #1180:
URL: https://github.com/apache/royale-asjs/issues/1180#issuecomment-1082271055


   Yes, the date value come from a server response...
   So what could I do ?
   
   thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@royale.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org