如何使用 NestJS 为 12:00AM 的多个国家编写调度程序(所有时区都相同)?

How write schedulers using NestJS for multiple countries at 12:00AM(will be same in all timezone)?

我有一个调度程序必须在印度时区 12:00 上午和新加坡时区 12:00 上午 运行。我能够为印度用户编写一个 cron 作业,但是如何在 12:00 AM 在新加坡触发相同的作业?

我认为很容易使用例如 9:30 PM (UTC+08:00(Singapore) - UTC+05:30(India)) AM 而不是 12:00 AM

如果使用此方法,只需编写一次代码,并从@Cron()装饰的两个函数中调用它

service.ts

@Injectable()
export class Service {
  @Cron('* * 0 * * *', {
    timeZone: 'Asia/Tehran', // use this website: https://momentjs.com/timezone/
  })
  async iran() {
    this.yourFunction();
  }

  @Cron('* * 0 * * *', {
    timeZone: 'Asia/Tokyo',
  })
  async japan() {
    this.yourFunction();
  }

  async yourFunction() {
    // write the schedule only one time
  }
}