Skip to content

Commit

Permalink
moved the use utc method to the JobManager
Browse files Browse the repository at this point in the history
  • Loading branch information
tallesl committed Apr 22, 2017
1 parent df84c00 commit c6d50ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
14 changes: 13 additions & 1 deletion Library/JobManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@ internal static DateTime Now
}

#endregion

#region UTC

/// <summary>
/// Use UTC time rather than local time.
/// It's recommended to call this method before any other library interaction to avoid mixed dates.
/// </summary>
public static void UseUtcTime()
{
_useUtc = true;
}

#endregion

#region Job factory

private static IJobFactory _jobFactory;
Expand Down Expand Up @@ -165,7 +178,6 @@ public static void InitializeWithoutStarting(Registry registry)
if (registry == null)
throw new ArgumentNullException("registry");

_useUtc = registry.UtcTime;
CalculateNextRun(registry.Schedules).ToList().ForEach(RunJob);
}

Expand Down
10 changes: 0 additions & 10 deletions Library/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class Registry
{
private bool _allJobsConfiguredAsNonReentrant;

internal bool UtcTime { get; private set; }

internal List<Schedule> Schedules { get; private set; }

/// <summary>
Expand All @@ -38,14 +36,6 @@ public void NonReentrantAsDefault()
}
}

/// <summary>
/// Use UTC time rather than local time.
/// </summary>
public void UseUtcTime()
{
UtcTime = true;
}

/// <summary>
/// Schedules a new job in the registry.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ That's why the least interval you can set is one second.
Unfortunately, not unlike many schedulers, there is no Daylight Saving Time support yet.

If you are worried about your jobs not running or running twice due to that, the suggestion is to avoid troublesome time
ranges or just `UseUtcTime()` in your registry.
ranges or just call `JobManager.UseUtcTime()` before using the library.

## Weekly jobs

Expand Down

0 comments on commit c6d50ae

Please sign in to comment.