Copy link to clipboard
Copied
I have searched everywhere, but can't find anything to help me get started on the Script. I would like a timesheet to auto populate the correct date based on the pay period and what week of the pay period, week 1 or week 2. Pay Periods are based on the Federal OPM Pay Calendar.
User inputs: Pay period and week of the pay period
Desire Outcome: Auto popluates Sundays (start of work week) date on time sheet
The timesheets are completed weekly. I have thought about reversing the inputs. User enters start date and the script auto popluates the week and pay period. Which ever is the easiest. First timer on script, but thanks to this community, I have knocked out everything else. Thank you!
Copy link to clipboard
Copied
if you search on this forum for "add days to date", you'll find plenty of code that will get you started. Searching on "timesheet dates" will provide more results, maybe even better ones for this question.
In fact, this exact question has been asked many times.
There are three parts to any time/date calculation
1) Convert a time/date string to a Date object
2) Perform calculation
3) Format resulting Date object/data into a date/time string.
Let's skip the first and last part and concentrate on the calculation using the date object.
This code adds one day (in place) to the date object.
var dtMyDate = ...
dtMyDate.setDay(dtMyDate.getDay()+1);
That's all there is to incrementing days.
You'll find more info on date and times here:
https://www.pdfscripting.com/public/Date-and-Time-Handling.cfm
https://acrobatusers.com/tutorials/date_time_part1/
https://acrobatusers.com/tutorials/date_time_part2/