javascript output in automator -
i trying create service in automator writes out formatted date string. have written javascript job, cannot figure out output string script. have tried log, console.log, this.console.log, write, , few other commands have found out there. not experienced @ javascript @ all; put piecemeal on couple of hours. here code have:
objc.import('cocoa'); rightnow = $.nsdate.date; dtformatter = $.nsdateformatter.alloc.init; dtformatter.datestyle = $.nsdateformatterfullstyle; dtformatter.timestyle = $.nsdateformattermediumstyle; formatteddate = dtformatter.stringfromdate(rightnow);
i under impression reading final line of code provide output, not seem case inside of run javascript action in automator. when code run in script editor, console displays formatted date expected.
thank counsel.
it turns out variable formatteddate needs "unwrapped" objective-c packaging:
the final code therefore:
objc.import('cocoa'); rightnow = $.nsdate.date; dtformatter = $.nsdateformatter.alloc.init; dtformatter.datestyle = $.nsdateformatterfullstyle; dtformatter.timestyle = $.nsdateformattermediumstyle; formatteddate = dtformatter.stringfromdate(rightnow); objc.unwrap(formatteddate)
Comments
Post a Comment