I am using agenda.js
in my Node project, backed with a MongoDB database, to handle batch processes we need to run. This is working well. I do have a question about timezones, however. When I use the every()
operation, it seems like it accepts the job name, and the schedule. So I have been seeding jobs to the database like so:
for (let job of dbJobs) {
await agenda.every(schedule, job.name);
}
Note that for the above, schedule
is in cron format -- 00 05 * * 1-5
.
This works. However, from what I can tell, every()
doesn't accept an argument for repeatTimezone
. So what does it do to calculate the timezone in those cases?
To clarify, when I look at the document in the database after the job has been added using every()
, the repeatTimezone
property exists, but its value is set to null
.
Other agenda
operations, like repeatEvery()
, do accept an argument for timezone, like so:
job.repeatEvery('0 6 * * *', {
timezone: 'America/New_York'
});
Since I'm using every()
, I have been managing this by first seeding the database using every()
, and then running a Mongo updateMany()
to add the timzeone explicitly to all jobs:
async function addTimezoneToJobs() {
try {
const db = await client.db(dbName);
await db.collection('batch_processes').updateMany({}, {
$set: {
repeatTimezone: 'America/New_York'
}
});
} catch (error) {
console.log(error);
}
}
But strangely enough, agenda
seems to calculate the same time even when I don't explicitly add the repeatTimezone
property value to the jobs as when I do.
What's happening here that I'm not understanding? How is the runtime calculated with every()
, and is there a way to pass in timezone?
FYI: I am not in the same timezone as that which needs to be set in the db.