From 702a5abdc52c78c007c43eb69e545f28538216e5 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sat, 7 Mar 2026 17:26:51 +0100 Subject: [PATCH] fix time zone mix.up --- .../Services/RecordingService.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Plugin.SRFPlay/Services/RecordingService.cs b/Jellyfin.Plugin.SRFPlay/Services/RecordingService.cs index 8244440..e8f1037 100644 --- a/Jellyfin.Plugin.SRFPlay/Services/RecordingService.cs +++ b/Jellyfin.Plugin.SRFPlay/Services/RecordingService.cs @@ -160,7 +160,7 @@ public class RecordingService : IRecordingService, IDisposable // Filter to only future/current livestreams that aren't blocked return livestreams - .Where(ls => ls.Blocked != true && (ls.ValidTo == null || ls.ValidTo > DateTime.UtcNow)) + .Where(ls => ls.Blocked != true && (ls.ValidTo == null || ls.ValidTo.Value.ToUniversalTime() > DateTime.UtcNow)) .OrderBy(ls => ls.ValidFrom) .ToList(); } @@ -333,13 +333,23 @@ public class RecordingService : IRecordingService, IDisposable foreach (var entry in _recordings.ToList()) { + // Normalize ValidFrom/ValidTo to UTC for correct comparison + var validFromUtc = entry.ValidFrom.HasValue ? entry.ValidFrom.Value.ToUniversalTime() : (DateTime?)null; + var validToUtc = entry.ValidTo.HasValue ? entry.ValidTo.Value.ToUniversalTime() : (DateTime?)null; + switch (entry.State) { case RecordingState.Scheduled: case RecordingState.WaitingForStream: // Check if it's time to start recording - if (entry.ValidFrom.HasValue && entry.ValidFrom.Value <= now.AddMinutes(2)) + if (validFromUtc.HasValue && validFromUtc.Value <= now.AddMinutes(2)) { + _logger.LogInformation( + "Time to start recording '{Title}': ValidFrom={ValidFrom} (UTC: {ValidFromUtc}), Now={Now}", + entry.Title, + entry.ValidFrom, + validFromUtc, + now); changed |= await TryStartRecordingAsync(entry, cancellationToken).ConfigureAwait(false); } @@ -347,7 +357,7 @@ public class RecordingService : IRecordingService, IDisposable case RecordingState.Recording: // Check if recording should stop (ValidTo reached or process died) - if (entry.ValidTo.HasValue && entry.ValidTo.Value <= now) + if (validToUtc.HasValue && validToUtc.Value <= now) { _logger.LogInformation("Recording '{Title}' reached ValidTo, stopping", entry.Title); StopFfmpeg(entry.Id);