Forum Bugs

moment.js library not working

ash
We have a PDF that we need to convert some dates to the users local timezone, so we've got moment.js loaded to help with this in our app.

When loading moment.js we get the common "Value is not an object" error

The issue seems to be that date.getTimezoneOffset() isn't supported by Prince Javascript, which is being used in moment.js, if I add Date.prototype.getTimezoneOffset = function() { return } for debugging purposes the pdf generates fine with moment.js included.

Is this going to be supported anytime soon? Am I missing something?
hallvord
Hi, I can confirm this method is missing - whether it's something Prince prioritises is a question for Mike Day. Since you (probably) know what time zone you are running Prince in, you can cheat and write a compat script that you run by simply passing an extra —script argument to Prince.


if (!Date.prototype.getTimezoneOffset)Date.prototype.getTimezoneOffset = function(){ return 240 }

Announcement: repos for tests/utils

hallvord
I added a compatibility shim script here, hope those who need Moment.js compatibility find it useful
https://github.com/yeslogic/prince-scripts/tree/master/compatibility/momentjs

Announcement: repos for tests/utils