Sign In Register

How can we help you today?

Start a new topic
Answered

Scope of time related expressions and more info

Hello,


During creation of leader boards we can use expressions like ${today} ${format(today,...)}. 


Is it possible to use those same expressions in cloud code, for example in order to display leader board for specific week i.e. leaderboardShortcode: SomeLeaderboard.week.${format(today, 'yyyyww')}?


Since there are more expressions than those mentioned in GS Documantation, can you post update of all available expressions we can use in cloud code or in events definitions?


Best Regards,

Sasha



Best Answer

Hi Sasha,


I'm afraid you can't use those expressions in Cloud code. You would have to use a combination of JavaScripts date methods or a custom method of your own to generate the fields required for retrieving a specific leaderboard by shortCode. As for the full list of expressions available, I'll raise this with our documentation team and get the list updated if there are more to be added.


Thanks,

Liam


1 person has this question

Answer

Hi Sasha,


I'm afraid you can't use those expressions in Cloud code. You would have to use a combination of JavaScripts date methods or a custom method of your own to generate the fields required for retrieving a specific leaderboard by shortCode. As for the full list of expressions available, I'll raise this with our documentation team and get the list updated if there are more to be added.


Thanks,

Liam

It's funny that he's asking about ${format(today, 'yyyyww')}. I feel like ${format(today, 'yyyyww')} doesn't seem to be following ISO 8601

https://en.wikipedia.org/wiki/ISO_8601


Currently I cannot get the same shortcode as the server using the servers own time 


In Layman's terms, right now (12/19/2016) when I create a new event in TestHarness its created with week 52 instead of week 51.


List of expressions I've found:


${today} - The epoch time of midnight today.

${now} - The current epoch time.

${today:minusDays(N)} - The epoch time of midnight N days ago.

${today:plusDays(N)} - The epoch time of midnight N days in the future.

${today:startOfWeek()} - The epoch time of midnight at the start of the week.

${today:startOfMonth()} - The epoch time of midnight at the start of the month.

${format(today, 'yyyyMMdd')} - The epoch time of midnight today formatted for [year][month][day] (Good for partitioning days)

${format(today, 'yyyyww')} - Doesn't seem to be following ISO_8601 (supposed to be for partitioning weeks)

${format(today, 'yyyyMM')} - The epoch time of midnight today formatted for [year][month] (Good for partitioning months)

I would suggest switching ${format(today, 'yyyyww')} to  ${format(today, 'yyyyMMWW')} 


This uses the week inside the month. so today it would output '20161204'

In this manner I was able to get everything matching though I'm not sure if this will have issues in the future.

Login to post a comment