Skip to content

Instantly share code, notes, and snippets.

@brainysmurf
Last active May 13, 2022 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brainysmurf/3cb92c8735ee96699d0b2a269ebe1761 to your computer and use it in GitHub Desktop.
Save brainysmurf/3cb92c8735ee96699d0b2a269ebe1761 to your computer and use it in GitHub Desktop.
function dailyTrigger() {
const end = new Date();
const start = new Date();
// the first of the current month
start.setDate(1);
// the last day of the current month
if (end.getMonth() === 11) {
end.setDate(31); // 31 days in Dec, always
} else {
// the 0 day of the next month is the last day of current month
end.setMonth(end.getMonth() + 1);
end.setDate(0);
}
// convert to YYYY-DD-MM ... make this bullet-proof
const start_date = `${start.getFullYear()}-${(start.getMonth()+1).toString().padStart(2, '0')}-${start.getDate().toString().padStart(2, '0')}`;
const end_date = `${end.getFullYear()}-${(end.getMonth()+1).toString().padStart(2, '0')}-${end.getDate().toString().padStart(2, '0')}`;
// call
run_MB_HRAttendance_byDate(start_date, end_date);
}
function run_MB_HRAttendance_byDate(start_date, end_date) {
const modules = MB_OA_Gsheets.modules();
// ...
const year_group_ids = []; // list of year_group_ids
// const start_date = 'YYYY-MM-DD';
// const end_date = 'YYYY-MM-DD';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment