HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Client/Server issue when sending DateTime  (Read 934 times)

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Client/Server issue when sending DateTime
« on: Aug 29, 14, 02:04:09 PM »

I recently discovered some inconsistency in how DateTimes are sent between client and server.  I have found that it usually compensates the time for the local client's time zone, but there is a case where is does not.

To recreate:
I created a class TestDateTime with the field _mt_startTime, and copied it so it is on both server and client sides.

Then defined these functions:

Server (in script cmdVoz)
Code: [Select]
function SendDTandTestObject(playerAcct as NodeRef of Class _playerAccount)
  dt as DateTime
  test as Class TestDateTime
  println("sending dt: "+dt+", test: "+test._mt_startTime)
  call client playerAcct VOZ:GetDTandTestObject(dt, test)
.
untrusted function GetDTandTestObject(dt as DateTime, test as Class TestDateTime)
  println("GetDTandTestObject dt: "+dt+", test._mt_startTime: "+test._mt_startTime)
.

Client (in script VOZ)
Code: [Select]
remote function GetDTandTestObject(dt as DateTime, test as Class TestDateTime)
  println("GetDTandTestObject dt: "+dt+", test._mt_startTime: "+test._mt_startTime)
.
function SendDTandTestObject()
  dt as DateTime
  test as Class TestDateTime
  println("sending dt: "+dt+", test: "+test._mt_startTime)
  call server cmdVoz:GetDTandTestObject(dt, test)
.

From server to client:
Quote
sending dt: 01/01/1900 06:00:00 UTC test: 01/01/1900 06:00:00 UTC
Quote
GetDTandTestObject dt: 01/01/1900 01:00:00, test._mt_startTime: 01/01/1900 01:00:00

From client to server:
Quote
sending dt: 01/01/1900 01:00:00, test: 01/01/1900 01:00:00
Quote
GetDTandTestObject dt: 01/01/1900 06:00:00 UTC, test._mt_startTime: 01/01/1900 01:00:00 UTC

As you can see, when I sent the same types from client to server, only the stand-alone DateTime was changed.  The field on the class object was not changed.  So it seems that might be a bug.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

HE-SCOTT

  • HeroEngine
  • *****
  • Posts: 158
    • View Profile
Re: Client/Server issue when sending DateTime
« Reply #1 on: Sep 04, 14, 02:17:14 PM »

We have added this to our internal bug tracking system and identified the specific case which fails. Times currently are assumed to be already in the UTC format when they are sent from the client as a class field.

That being said times sent from the client should never be trusted or used in the server. Time on a clients computer can be changed easily and no assumptions can be made about it. We take care to ensure correct time UTC within each server  cluster and provide access to that with the SYSTEM.TIME.NOW value. This value should be used when tracking datetimes.

Here is a good article about some of the things that can effect time results from a computer and thus why you can't use time values from a client http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time
« Last Edit: Sep 04, 14, 02:22:08 PM by HE-SCOTT »
Logged