import cron from 'node-cron';
import { syncEmpleadosToExternalDB } from './sync-empleados.js';

// Example cron job, runs every 5 seconds for demonstration/testing.
cron.schedule('*/5 * * * * *', () => {
  const now = new Date();
  if (!isNaN(now)) {
    const formatted = now.toISOString(); // ✅ siempre funciona, sin locales
    console.log('[cron]', formatted);
  } else {
    console.log('[cron] Fecha inválida');
  }
});

// // Schedules the daily employee data synchronization to run at midnight.
// cron.schedule('0 0 * * *', () => {
//   console.log('[CronWorker] Running daily employee synchronization task...');
//   syncEmpleadosToExternalDB().catch(err => {
//     console.error('[CronWorker] Error during scheduled employee synchronization:', err);
//   });
// });
// console.log('[CronWorker] Daily employee synchronization task scheduled for 00:00.');
