question

mchen0358 avatar image
mchen0358 asked

TitleNews timeStamp return result actionscript 3 SDK

Did the titleNews TimeStamp response change?

I got the result from response is "2017-06-15T07:30:00Z".

And when construct the TitleNewsItem from GetTitleNewsResult, it was using PlayfabUtil.parseDate(data:String) function to parse the timeStamp and return "Invalid date"


I was using actionscriptSDK and i debugged that the milisecond value is undefined when parsing the timeStamp using regexp.

Note: result[7] and result[8] is undefined

	    var year:Number = parseInt(result[1]);
            var month:Number = parseInt(result[2]);
            var day:Number = parseInt(result[3]);


            var hour:Number = parseInt(result[4]);
            var minute:Number = parseInt(result[5]);
            var second:Number = parseInt(result[6]);


            var milliseconds:Number = 0;
            if(result.length == 9)
                milliseconds = parseInt(result[8])
Title News
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1807605288 avatar image
1807605288 answered

It is absolutely intended that you should be able to use PlayFabUtil.parseDate(). I can also confirm that there's an error in that function, specifically with our TimeStamp regex here.

It won't parse a timestamp unless the timestamp is formatted like this:
"2017-06-15T07:30:00.0Z"
(Note the extra ".0" milliseconds)

I have to brush up on my regex, and figure out why the ? in the regex parser:

new RegExp("(\\d+)\\-(\\d+)\\-(\\d+)T(\\d+)\\:(\\d+)\\:(\\d+)(\\.(\\d+))?Z?", "x");

isn't doing it's job.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1807605288 avatar image 1807605288 ♦ commented ·

I have found the issue. The fix is now submitted to the auto-builder, and will be available in the next published version of AS3-SDK: 0.48

0 Likes 0 ·
brendan avatar image
brendan answered

It does look like the regex in the SDK does not handle cases where the milliseconds are missing. And the service is not returning milliseconds if they're exactly 0. We're checking to see if that's a regression, but one quick way to fix this for your title is to ensure that your news items always have non-zero milliseconds.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mchen0358 avatar image mchen0358 commented ·

How to make the title news has non-zero milliseconds from game center?

0 Likes 0 ·
brendan avatar image brendan mchen0358 commented ·

Actually, just change this line:

if(result.length == 9)

To this:

if(result.length == 9 && result[8])

That should fix the issue for you. We'll have an updated SDK live soon.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.