Closed snehilmodani closed 8 years ago
In the on premise installation you normally do:
npm install moment-timezone --save
dev|prod.config.json
and alter tasks.allowedModules
{ "tasks": { "allowedModules": '*' } })
var moment = require('moment-timezone');
moment().tz("America/Los_Angeles").format();
In the jsreportonline, you don't have control over configuration. We may add moment timezone in future releases, but until then you can workaround it by adding the timezone code at the bottom of the helpers. See it here https://playground.jsreport.net/studio/workspace/HkqFhP6c/3 (Note on jsreportonline, you should add just timezone code, because moment is already there) It is not so pretty, I know. I've in mind a new extension that allows to upload any kind of file and reference it form helpers/html. It should come in couple of months.
The workaround works fine! Looking forward to this new extension.
I can use "moment" in the helper functions but also need "moment-timezone" for a few other functionalities. I found this piece of code which i think can help me around it, but I am not able to figure out how and where to use it:
I am keen to know how it works too.
Note: We are using jsreport server for development and jsreportonline for our production environments.
On a side note if you add moment-timezone too in the default loading of the allowed modules as it would help all developers manage data across timezones without much hassle.