mirror of
https://github.com/kevincolyar/CronNET.git
synced 2025-03-11 08:19:40 +01:00
Add timezone offset to CronDaemon
This commit is contained in:
parent
bfe1a1f92c
commit
bd9551f015
|
@ -16,7 +16,8 @@ namespace CronNET
|
|||
{
|
||||
private readonly System.Timers.Timer timer = new System.Timers.Timer(30000);
|
||||
private readonly List<ICronJob> cron_jobs = new List<ICronJob>();
|
||||
private DateTime _last= DateTime.Now;
|
||||
private DateTime _last = DateTime.Now;
|
||||
private int _timezone_offset = 0;
|
||||
|
||||
public CronDaemon()
|
||||
{
|
||||
|
@ -24,6 +25,13 @@ namespace CronNET
|
|||
timer.Elapsed += timer_elapsed;
|
||||
}
|
||||
|
||||
public CronDaemon(int timezoneOffset)
|
||||
{
|
||||
timer.AutoReset = true;
|
||||
timer.Elapsed += timer_elapsed;
|
||||
_timezone_offset = timezoneOffset;
|
||||
}
|
||||
|
||||
public void AddJob(string schedule, ThreadStart action)
|
||||
{
|
||||
var cj = new CronJob(schedule, action);
|
||||
|
@ -49,7 +57,7 @@ namespace CronNET
|
|||
{
|
||||
_last = DateTime.Now;
|
||||
foreach (ICronJob job in cron_jobs)
|
||||
job.execute(DateTime.Now);
|
||||
job.execute(DateTime.UtcNow.AddHours(_timezone_offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user