Sign In Register

How can we help you today?

Start a new topic

moment.js

Hi,


Our cloud code needs to do a lot of date/time processing and we would like to use moment.js. Is it something you would consider to offer in your backend?


1 person likes this idea

Hi Christian,


What sort of date/time processing required here that can't be done in Cloud Code right now ?


Thanks,

Liam

Hi Liam,


The cloud code generates personalized emails to players with event dates. So from a js date and a timezone, I need a human readable date. The main challenge here is to properly support daylight saving time.

 

We also need to add days to a date. We cannot simply do that: newDate = date + (nbDays * 86400000), we have to consider daylight saving time.

 

moment.js properly support daylight saving time.


We are facing the same problem right now. We decided to let the client do all date/time callculations because it knows it's time zone.

For that we send the clients time zone ID with the account details request and store it in ScriptData. After that every client can do calculations for that player with the time zone ID.

Sadly the TimeZoneInfo class is currently broken in Unity, so you have to implement some workarounds (if you are using unity).

moment is a GREAT package. We're having the issue now, too.

I've spent a couple of fruitless days trying to get moment timezone to work in GS cloudcode land to no avail...

What keeps you from adding Moment.js and other packages as module and using it by require() from there?

Getting Moment to work is easy enough ... getting moment timezone (which relies on moment) is much harder...

 

Login to post a comment