0

I'm new to Indesign Scripting, but I'm working on an InDesign CC Script, where I would need to work a lot with date-functions.

I wanted to know if it's possible to import a JS Library like date.js or moment.js in Extendscript for that matter?

Cheers

der-lukas
  • 936
  • 9
  • 13

1 Answers1

1

It depends on the library. If the lib is using browser specific functions then not. I had a quick test with date.js and it seems to work. (Like this)

#include "date.js"
var d = Date.today().is().friday();
$.writeln (d);
fabianmoronzirfas
  • 4,091
  • 4
  • 24
  • 41
  • Browser specific ... or anything else that was added to EcmaScript after around 1995 :) I sure could use stuff such as byte arrays! – Jongware Dec 01 '14 at 13:25
  • Awesome, thank you! One more question: where did you put the date.js file? In the same directory as the script? – der-lukas Dec 01 '14 at 16:02
  • der-lukas yes. I'ts a relativ path for the include. @Jongware really? 1995 awful. ;( – fabianmoronzirfas Dec 01 '14 at 20:22
  • @fabiantheblind Done! Thanks again! I'll post some experiences I made later for future reference later! :) – der-lukas Dec 02 '14 at 07:56
  • @fabiantheblind I got one more little question: I can only run my script from Extendscript Toolkit. When I run it from the Scriptpanel, Extendscript Toolkit opens the date.js-File and gives me an Error Message. Could this be an issue, because ExtendScript doesn't understand all functions of date.js? – der-lukas Dec 08 '14 at 15:23
  • it is possible that some functions are missing. depends on what error you get. I'm collecting prototypes I found useful here https://github.com/fabiantheblind/extendscript.prototypes you can compile it buy running `npm install && grunt build` – fabianmoronzirfas Dec 08 '14 at 19:02