3 Replies Latest reply on Jun 13, 2012 1:28 PM by Ned Murphy

    Date() - Buggy behaviour working with Number() or uint()

    Filippo Gregoretti Level 1

      It took me half day to track down this, apparently it is a bug (I don't know if there is some obscure logic behind it).


      Date() behaves much differently when casted/created with the same amount as Number() or uint()

      Here is the output when tracing:


      new Date()= Wed Jun 13 20:12:43 GMT+0200 2012
      new Date().time= 1339611163266
      Number(new Date())= 1339611163266
      uint(new Date())= 3876334210
      new Date(Number(1339610984911))= Wed Jun 13 20:09:44 GMT+0200 2012
      new Date(uint(1339610984911))= Sat Feb 14 21:42:35 GMT+0100 1970


      As you can see, converting a date to Number(new Date()) or uint(new Date()) gives a completely different result.


      Also, working with the same time amount, if new Date(Number(time)) or new Date(uint(time)) returns a completely different date.


      So, even though milliseconds from 1st jan 1970 are obviously an integer, AS3 treats it differently if casted to Number or uint.


      Is there a logic? To me it looks like a bug...