So the CreateChallengeRequest can't parse "2015-01-11T14:00:58.267Z" but it CAN parse "2015-01-11T14:00Z"!
The bizarre thing here is that if I try to do Date.parse("2015-01-11T14:00Z") I get NaN.
So Date.parseCAN'Tparse the string that GameSparks requires.
Am I doing something wrong? or is this just weird?
Best Answer
C
Customer Support
said
over 7 years ago
Hi Cory,
I replicated your problem and came up with this as a temporary solution:
var battleEndDate = new Date(Date.now()+(1000*60*60*24));
var newDate = battleEndDate.getFullYear()+ "-" + battleEndDate.getUTCMonth() + 1 +"-"+ battleEndDate.getUTCDate() + "T" + battleEndDate.getUTCHours() +":" + battleEndDate.getUTCMinutes()+ "Z";
This returned: 2015-01-13T11:10Z
I think the problem here might be that for our challenges we round it up to the nearest minute so we can batch the challenges instead of firing them off whenever comes in.
So when GameSparks sees 2015-01-11T14:00:58.267Z sees it doesn't know what to do.
I replicated your problem and came up with this as a temporary solution:
var battleEndDate = new Date(Date.now()+(1000*60*60*24));
var newDate = battleEndDate.getFullYear()+ "-" + battleEndDate.getUTCMonth() + 1 +"-"+ battleEndDate.getUTCDate() + "T" + battleEndDate.getUTCHours() +":" + battleEndDate.getUTCMinutes()+ "Z";
This returned: 2015-01-13T11:10Z
I think the problem here might be that for our challenges we round it up to the nearest minute so we can batch the challenges instead of firing them off whenever comes in.
So when GameSparks sees 2015-01-11T14:00:58.267Z sees it doesn't know what to do.
Shane
S
Stephen Swan
said
over 6 years ago
Hi,
I have been trying to implement this solution but with no success. Your solution creates a string but createCreateChallengeRequest().setEndTime() will not accept a string and requires a date class. I suspect it's looking for a Java date class but of course it's getting an as3 one. I have tried to apply the principles of your solution by creat8ng a new date with the seconds rounded off (in fact I have rounded to the nearest day which is fine for me). My code for this is as follows:
public static function createChallenge(vID:Vector.<String>):void { var endDate:Date = new Date();
var endYear:Number = endDate.fullYear; var endMonth:Number = endDate.month; var endDay:Number = endDate.date + 2; var roundDate:Date = new Date(endYear, endMonth,endDay);
You'll notice that the rounded date is correct in that it goes to midnight the day after today. However the date that is being parsed is back just over one month. I have tried pushing it forward by adding months but, whilst the rounded date goes forward it does not change the parsing problem (and the date that comes back is actually even more confused!).
Note also your documentation suggests that this end date is not required but, even from within test harness, it appears it is required.
It would be great if I could simply pass in a string as supposed by your solution but I can't get that to work.
Thanks
Stephen
J
Juan Fernando Velez
said
over 6 years ago
Hi, Is there any advance in this error?, I have the same problem, with this error it seems GameSparks will be completely useless for Adobe AIR/Flex Game developers since the Challenges capabilities can't be used.
Thanks in advance...
S
Stephen Swan
said
over 6 years ago
Hi Juan,
Yes there is but on another ticket ( https://support.gamesparks.net/support/tickets/1695 ) which focuses on this purely from an actionscript perspective.
At the moment there is a new sdk to download (see the link provided on that ticket) which does solve the main problem. There is still a continuing issue with the date that is being created being off by a little over a month so you could simply adjust for this but Gamesparks are working on a better solution. Gamesparks are still working on that and given their excellent support so far it will probably be fairly soon.
Cheers
Stephen
J
Juan Fernando Velez
said
over 6 years ago
Hi Stephen,
Thanks for your answer, the link you provided doesn't work, can you give us the download link here?
You may still be better to search the forum for the other thread as I am still waiting for the final part of the piece getting the date right and that's where it will get posted. Just go to tickets and search for ticket number 1695.
Cory Leach
I have the following event code which attempts to send CreateChallengeRequest as the current player:
var player = Spark.getPlayer();
var battleEndDate = new Date(Date.now()+(1000*60*60*24));
var request = {};
request["@class"] = ".CreateChallengeRequest";
request["challengeShortCode"] = "Battle";
request["usersToChallenge"] = [player.getPlayerId()];
request["endTime"] = battleEndDate.toISOString();
//Issue Battle Challenge to Self
var response = Spark.sendRequest(request);
var parsedDate = Date.parse(request["endTime"]);
Spark.setScriptData("parsedDate", parsedDate);
Spark.setScriptData("request", request);
Spark.setScriptData("response", response);
The really strange thing is that I get an error message saying that endTime could not be parsed:
So the CreateChallengeRequest can't parse "2015-01-11T14:00:58.267Z" but it CAN parse "2015-01-11T14:00Z"!
The bizarre thing here is that if I try to do Date.parse("2015-01-11T14:00Z") I get NaN.
So Date.parse CAN'T parse the string that GameSparks requires.
Am I doing something wrong? or is this just weird?
Hi Cory,
I replicated your problem and came up with this as a temporary solution:
This returned: 2015-01-13T11:10Z
I think the problem here might be that for our challenges we round it up to the nearest minute so we can batch the challenges instead of firing them off whenever comes in.
So when GameSparks sees 2015-01-11T14:00:58.267Z sees it doesn't know what to do.
Shane
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Cory,
I replicated your problem and came up with this as a temporary solution:
This returned: 2015-01-13T11:10Z
I think the problem here might be that for our challenges we round it up to the nearest minute so we can batch the challenges instead of firing them off whenever comes in.
So when GameSparks sees 2015-01-11T14:00:58.267Z sees it doesn't know what to do.
Shane
Stephen Swan
Hi,
I have been trying to implement this solution but with no success. Your solution creates a string but createCreateChallengeRequest().setEndTime() will not accept a string and requires a date class. I suspect it's looking for a Java date class but of course it's getting an as3 one. I have tried to apply the principles of your solution by creat8ng a new date with the seconds rounded off (in fact I have rounded to the nearest day which is fine for me). My code for this is as follows:
public static function createChallenge(vID:Vector.<String>):void
{
var endDate:Date = new Date();
var endYear:Number = endDate.fullYear;
var endMonth:Number = endDate.month;
var endDay:Number = endDate.date + 2;
var roundDate:Date = new Date(endYear, endMonth,endDay);
requestBuilder.createCreateChallengeRequest()
.setAccessType("PRIVATE")
.setChallengeMessage("Riddle Challenge")
.setChallengeShortCode("friendChallenge")
.setEndTime(roundDate)
.setUsersToChallenge(vID)
.send(challengeResponseHandler);
}
The output from this is as follows:
endDate: Mon Mar 7 16:28:34 GMT+0000 2016
roundDate: Wed Mar 9 00:00:00 GMT+0000 2016 - ChallengeErrors HasErrors(): true -
ChallengeErrors stringifyresponse:
{"message":"java.text.ParseException: Unparseable date: \"2016-02-03-T00:00Z\" (through reference chain: com.gamesparks.messages.requests.CreateChallengeRequest[\"endTime\"])"} :
You'll notice that the rounded date is correct in that it goes to midnight the day after today. However the date that is being parsed is back just over one month. I have tried pushing it forward by adding months but, whilst the rounded date goes forward it does not change the parsing problem (and the date that comes back is actually even more confused!).
Note also your documentation suggests that this end date is not required but, even from within test harness, it appears it is required.
It would be great if I could simply pass in a string as supposed by your solution but I can't get that to work.
Thanks
Stephen
Juan Fernando Velez
Is there any advance in this error?, I have the same problem, with this error it seems GameSparks will be completely useless for Adobe AIR/Flex Game developers since the Challenges capabilities can't be used.
Thanks in advance...
Stephen Swan
Hi Juan,
Yes there is but on another ticket ( https://support.gamesparks.net/support/tickets/1695 ) which focuses on this purely from an actionscript perspective.
At the moment there is a new sdk to download (see the link provided on that ticket) which does solve the main problem. There is still a continuing issue with the date that is being created being off by a little over a month so you could simply adjust for this but Gamesparks are working on a better solution. Gamesparks are still working on that and given their excellent support so far it will probably be fairly soon.
Cheers
Stephen
Juan Fernando Velez
Thanks for your answer, the link you provided doesn't work, can you give us the download link here?
Stephen Swan
Hi Juan,
Here's the link to the download:
Here's the link to the SDK: https://bitbucket.org/gamesparks/gamesparks-as3-sdk/downloads
You may still be better to search the forum for the other thread as I am still waiting for the final part of the piece getting the date right and that's where it will get posted. Just go to tickets and search for ticket number 1695.
Cheers
Stephen
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics