Have you checked the JavaSvript console for any errors?
You have a number of syntax errors and an undefined function.
I'm new to this. Sorry. I'm not sure how I do that. If you see issues with the code, can you tell me what you would do to correct them?
var MonthEnded = thisgetField("Month Ended").value;
Has a syntax error. You have not indicated made clear what the object and method you want to use. "getField" is a method of the document or doc object. An object is separated from the method to be used by a ".". It should read:
var MonthEnded = this.getField("Month Ended").value;
There is no predefined or provided method or function "moveToLastDayofMonth()".
It is possible to get the last day of a month from a date object. It takes some additional lines of code to advance the date object to the first of the month 2 months from the date entered and then backup one day.
There are a number of problems with your code. Let's first talk about the syntax errors:
This is the code as you've quoted it:
var MonthEnded = thisgetField("Month Ended").value; MonthEnded.moveToLastDayOfMonth(); MonthEnded.addMonths(1); MonthEnded.moveToLastDayofMonth(); event.value = util.printd("mm/dd/yyyy",MonthEnded");
In line 1, you need a period between "this" and "getField".
To include this library, download it from http://www.datejs.com/
The best way to add it to your system is to create a folder level script - this way you can make sure that it only gets included once. If that is not possible because you are trying to distribute your document outside of your organization, then the next best thing is to create a document level script (e.g. call it DateJS) and add the whole library. Now you should be able to use in in your code. But that will bring up other problems:
var MonthEnded = new Date(this.getField("Month Ended").value); MonthEnded.moveToLastDayOfMonth(); MonthEnded.addMonths(1); MonthEnded.moveToLastDayOfMonth(); event.value = util.printd("mm/dd/yyyy", MonthEnded);
I tried adding date.js to Acrobat as-is but not everything worked as I would have expected so I made some modifications and additions and your timing couldn't be better.
I'm a couple of days away from publishing my own Date Library for Acrobat that does a lot of the stuff that date.js does as well as some of the stuff that PHP Carbon does. It also adds the util.scand functionality into the Mobile JS interpreter. It'll be distributed as a custom command that inserts the script into the document. Totally free to use, distribute, and modify.
If anyone on this thread is interested in testing it with me, contact me directly.
thanks of the heads up. All I did was to add the library to a document level script and check for error messages on the console. The functionality used in the script above does work, but again, I don't know about any undesired side effects, or other areas in DateJS. I am glad to hear that you are working on something to provide more functionality to Acrobat's date processing.
Keep in mind that - as Joel indicated - not all functionality of DateJS will work correctly, and we don't even know if what you are trying to do will work in all cases.
You paste the complete code of the library into the editor window - replacing everything that's there - after you click on the Add button.
That worked. I really appreciate your help. Thank you for taking the time to answer my questions even though they were probably very elementary. It was very kind.