If I take the raw content of datejs
, and save it to a file called date
(or more accurately date.js
) in Scriptable, I can then add the following line after the comments, and successfully call a datejs
function as below.
//Add this to datejs; not sure if this is good practice to be doing this with "Date", but anyhow...
module.exports.Date = Date;
//Put this in a new Scriptable file, to import the module and bind it to 'datejs'
const datejs = importModule("date.js");
console.log(datejs.Date.today().next().friday());
There could well be a better option, but I’ve only ever tried to use my own modules in Scriptable specifically, and I’ve always defined the exports myself as I’ve gone along. The above feels like it is a bit of a retrofit and feels clunky to me.
You could use the direct evaluation I used before we had importModule()
and that should get you out of the extra datejs
object use each time - if you just use the functions directly at the end of the date.js
file that’s the same basis as the direct evaluation. I’m not recommending this approach. Direct evaluation is definitely kinda hacky. I’m just noting it as an option.
Hope something in that helps.