I’m struggling getting timezones and task scheduling work properly on a Nest.js 9 project. For reference, this is the docs for the library: https://docs.nestjs.com/v9/techniques/task-scheduling
This is a brief explanation on the current situation… Let’s imagine I want to execute a function at 10:00 A.M Buenos Aires time (GMT-3). This timezone should be equivalent to 09:00 A.M New York time (GMT-4).
So, if I’m in Buenos Aires, and I write this code:
const cronExecutionDate = new Date('2024-09-23T08:00:00');
const job = new CronJob(cronExecutionDate, () => console.log('Logging via cron job!'), null, true, 'America/New_York');
I should see the console log statement executing at 09:00 A.M my time. However, I’m not actually seeing that, but the console.log executes at 08:00 A.M my time, even though I’m one hour ahead.
On the other hand, let’s say that my time is 08:00 A.M. If I set the scheduled date as 07:30 A.M in America/New_York timezone, Nest.js throws an error, saying that the date I specified is in the past, even though that’s not true for my timezone, since the equivalent in America/Buenos_Aires is 08:30 A.M.
Could you guys help me figure this out?