From 31c1d2804ddda6989b24b031495ccb489ad0bc64 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Thu, 6 Feb 2025 16:27:20 +0300 Subject: [PATCH] fix: hotfix calculate next run time --- Endpoint/Common/Services/CronUpdateSkipService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Endpoint/Common/Services/CronUpdateSkipService.cs b/Endpoint/Common/Services/CronUpdateSkipService.cs index 802dd64..8ecfa23 100644 --- a/Endpoint/Common/Services/CronUpdateSkipService.cs +++ b/Endpoint/Common/Services/CronUpdateSkipService.cs @@ -37,7 +37,7 @@ public static class CronUpdateSkipService .OrderBy(x => x.End ?? x.Date) .ToList(); } - + public static List GetNextTask(this List data, CronExpression expression, int depth = 1, DateOnly? currentDate = null) @@ -45,8 +45,8 @@ public static class CronUpdateSkipService if (depth <= 0) return []; - currentDate ??= DateOnly.FromDateTime(DateTime.UtcNow); - DateTimeOffset nextRunTime = currentDate.Value.ToDateTime(new TimeOnly(0, 0, 0)); + currentDate ??= DateOnly.FromDateTime(DateTime.Now); + DateTimeOffset nextRunTime = currentDate.Value.ToDateTime(TimeOnly.FromDateTime(DateTime.Now)); List result = []; @@ -59,7 +59,7 @@ public static class CronUpdateSkipService else if (lastSkip.Date.HasValue) nextRunTime = new DateTimeOffset(lastSkip.Date.Value.AddDays(1), new TimeOnly(0, 0, 0), TimeSpan.Zero); - var next = expression.GetNextOccurrence(nextRunTime, TimeZoneInfo.Local); + var next = expression.GetNextOccurrence(nextRunTime.ToUniversalTime(), TimeZoneInfo.Local); if (!next.HasValue) return result;