0

I am trying to pass a number (date in ms) to a function in a library module. The number gets screwed up!

Here is a simple look (function MailUtils.showNum has only one line, the same log call as seen below):

n = Number(todayMs - mbRetMs);
Logger.logDebug("Num = " + n + "; as Date = " + new Date(n));
MailUtils.showNum(n);

Log:
/* Num = 1500396760628; as Date = Tue Jul 18 2017 12:52:40 GMT-0400 (EDT) */
/* Num = 1453174324; as Date = Sat Jan 17 1970 14:39:34 GMT-0500 (EST) */

Seriously ???

What the * is happening? Looks like it somehow figures out it is a date and passes the origin date (the date the ms are counted from)?

Crashmeister
  • 375
  • 1
  • 14

1 Answers1

0

LOL, Int32 Overflow #Fail. What you’re seeing is your original [64-bit] integer's 32 Least Significant Bits; the high bits have all been stripped.

Odd in itself, since JS uses Double internally; presumably a bug in JXA. (It has a lot of those.)

If you like JavaScript I strongly recommend using Node.js instead. JXA is rubbish in comparison, and with OSA technologies now in maintenance mode I don’t imagine it’ll ever get fixed.

has
  • 92
  • 1