Jump to content


Photo

Are date/time functions broken in HTML5 (bug?)


  • Please log in to reply
2 replies to this topic

#1 Rekulath

Rekulath

    GMC Member

  • GMC Member
  • 18 posts

Posted 18 February 2012 - 06:08 PM

I've been tearing my hair out for a week now trying to figure out what is going on with the functions I have been using to track persistence in my game in html5. I am using a simple system of storing the last played time of the user when the game saves in an ini using date_current_datetime(). When the user continues the game next time, the game compares date_current_datetime() to what was stored in the ini and returns the difference in seconds using floor(date_second_span(date1,date2)) essentially. This all works fine with no problems when running the windows version of the game, returning the time passed rounded to the nearest second. What happens when running the game in html5 though, is the numbers returned for date_second_span() become completely screwy. It will return very very small decimal numbers like 0.0006944444~ for the seconds passed. This is not a problem with my ini as I load all of the game variables through it and everything else in the game loads perfectly. I have even tested comparing two created datetimes, using date_create_datetime. Even doing this with different times returns crazy small decimal values when using date_second_span. Am I doomed to tear my hair out for another week or is there anyone out there with a simple or obvious answer that could help me out?

As a tangent, is there any way for the game to continue running if that particular browser window isn't the main focus? Even so much as opening a new browser tab completely pauses the game, but I assume this is intended? It does work if it loses focus (ie. Windows live messenger window opens in front of the browser) but alt tabbing or doing anything to send the browser window down to the taskbar pauses it. I noticed similar behavior in GM8 in that the game completely pauses if minused to the taskbar, but yet there it will keep running if you alt tab or switch windows.

Edited by Rekulath, 21 February 2012 - 12:49 AM.

  • 0

#2 Rekulath

Rekulath

    GMC Member

  • GMC Member
  • 18 posts

Posted 21 February 2012 - 12:57 AM

As another test I made a new blank project and tried:

date1=date_create_datetime(2012,02,20,16,45,0)
date2=date_create_datetime(2012,02,20,16,46,0)

seconds_passed=date_second_span(date1,date2)

Running in windows, seconds_passed returns the number 60 as expected, however in html5 the number 0.0006944444477558136 is returned. Is there something glaringly obvious that I've missed? I've had a bit of experience with GML but am very new to html5 and javascript so perhaps there is another way I could go about what I'm trying to accomplish?

edit: I was able to search and finally find the wiki link that shows current_time as being broken in html5 and always returning 0, which explains most likely why none of the functions are working.

Edited by Rekulath, 21 February 2012 - 01:38 AM.

  • 0

#3 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 1497 posts
  • Version:GM:Studio

Posted 21 February 2012 - 08:25 AM

All datetime stuff has been fixed, but I'm not sure it's been released yet. Check it on the next release.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users