1

very strange issue I am seeing. I have attached 2 screenshots, one of which is on Android the other is on iOS. When I test my app on emulator, I get the correct number. When I test on Android, I get the correct number. But when it's on iOS, for some reason my Math.Ceil (in javascript) returns a NaN number on iOS. Here's my function currently:

 var diffHours = Math.ceil((today.getTime() - creDate.getTime()) / (60 * 60 * 1000));
            if (diffHours < 1) {
                tmp[k].Difference = "Posted < 1 hours ago.";
            } else {
                tmp[k].Difference = "Posted " + diffHours + " hours ago.";
            }

Where diffHours returns NaN on iOS only (So I know this is not a math issue, the number I get is correct just not on iOS).

Anyone have any idea why this could be?

If not, is there an alternative I can use to Math.Ceil that I can use that will give me same result?

UPDATE

Here are one examples of values that's being passed in

today = Fri Aug 28 2015 12:25:30 GMT-0500 (Central Daylight Time) 
creDate = Thu Aug 27 2015 00:06:54 GMT-0500 (Central Daylight Time)

Attached Images (sorry the size is so big):

  • Android

Correct_Math_Ceil

  • iOS

enter image description here

  • Need to see entire example as value of some variable are unknown in posted code.. – Rayon Aug 28 '15 at 17:06
  • @RayonDabre I think this is an iOS issue, not code. As you see, same thing on Android gets correct number. As I stated, I do not believe this is a math issue for I get the correct number in plain javascript/emulator and on the actual android device. These 2 screenshots are from the same account, same page, same everything. Just on iOS I'm getting 'NaN' from a Math.Ceil function. I think this may be an issue for anyone using Math.Ceil in a Hybrid App on iOS. –  Aug 28 '15 at 17:07
  • 1
    Yes, iOS do have some issues with Date functions, I would suggest you to refer this links http://stackoverflow.com/questions/13363673/javascript-date-is-invalid-on-ios or http://stackoverflow.com/questions/5324178/javascript-date-parsing-on-iphone – Rayon Aug 28 '15 at 17:11
  • I'm not sure if that's it, I tried both with no prevail. But I did update my post with actual numbers so you can see what's being passed in. –  Aug 28 '15 at 17:26
  • Looks good to me...It needs some serious debugging i suppose.. – Rayon Aug 28 '15 at 17:34

0 Answers0