Skip to content

Commit

Permalink
Use local time in displayed dates
Browse files Browse the repository at this point in the history
  • Loading branch information
shemanaev committed Feb 26, 2024
1 parent 8bc13ca commit 4347ebd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion MediaCleaner/Filtering/ExpiredNotPlayedFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public List<ExpiredItem> Apply(List<ExpiredItem> items)
var expirationTime = item.Item.DateCreated.AddDays(_keepFor);
if (DateTime.UtcNow.CompareTo(expirationTime) < 0) continue;

_logger.LogTrace("Not played by anyone since {DateAdded}", item.Item.DateCreated);
_logger.LogTrace("Not played by anyone since {DateAdded}", item.Item.DateCreated.ToLocalTime());
result.Add(item);
}

Expand Down
2 changes: 1 addition & 1 deletion MediaCleaner/ItemsAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public IEnumerable<ExpiredItem> GetPlayedItems(
if (userData.LastPlayedDate < item.DateCreated)
{
_logger.LogWarning("Ignoring \"{Name}\" ({Id}): played by \"{Username}\" at {LastPlayedDate}, but added at {DateCreated}",
item.Name, item.Id, user.Username, userData.LastPlayedDate, item.DateCreated);
item.Name, item.Id, user.Username, userData.LastPlayedDate.Value.ToLocalTime(), item.DateCreated.ToLocalTime());
continue;
}

Expand Down
28 changes: 14 additions & 14 deletions MediaCleaner/MediaCleanupTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public async Task ExecuteAsync(IProgress<double> progress, CancellationToken can

foreach (var item in expired)
{
var expiredForUsers = string.Join(", ", item.Data.Select(x => $"{x.User.Username} ({x.LastPlayedDate})"));
var expiredForUsers = string.Join(", ", item.Data.Select(x => $"{x.User.Username} ({x.LastPlayedDate.ToLocalTime()})"));
_logger.LogInformation("({Type}) \"{Name}\" will be deleted because expired for: {Users}",
item.Item.GetType().Name, item.FullName, expiredForUsers);

Expand Down Expand Up @@ -214,7 +214,7 @@ public async Task ExecuteAsync(IProgress<double> progress, CancellationToken can
foreach (var item in expiredNotPlayed)
{
_logger.LogInformation("({Type}) \"{Name}\" will be deleted because no one played it since {DateCreated}",
item.Item.GetType().Name, item.FullName, item.Item.DateCreated);
item.Item.GetType().Name, item.FullName, item.Item.DateCreated.ToLocalTime());

if (IsDryRun) continue;

Expand Down Expand Up @@ -516,8 +516,8 @@ private async Task CreateNotification(ExpiredItem item)
title = $"\"{movie.Name}\" was deleted";
shortOverview = item.Kind switch
{
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated}",
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate.ToLocalTime()}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated.ToLocalTime()}",
_ => throw new NotImplementedException(),
};
overview = $"{movie.Path}";
Expand All @@ -527,8 +527,8 @@ private async Task CreateNotification(ExpiredItem item)
title = $"\"{series.Name}\" was deleted";
shortOverview = item.Kind switch
{
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated}",
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate.ToLocalTime()}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated.ToLocalTime()}",
_ => throw new NotImplementedException(),
};
overview = $"{series.Path}";
Expand All @@ -538,8 +538,8 @@ private async Task CreateNotification(ExpiredItem item)
title = $"\"{season.SeriesName}\" S{season.IndexNumber:D2} was deleted";
shortOverview = item.Kind switch
{
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated}",
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate.ToLocalTime()}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated.ToLocalTime()}",
_ => throw new NotImplementedException(),
};
overview = $"{season.Path ?? season.SeriesPath}";
Expand All @@ -549,8 +549,8 @@ private async Task CreateNotification(ExpiredItem item)
title = $"\"{episode.SeriesName}\" S{episode.ParentIndexNumber:D2}E{episode.IndexNumber:D2} was deleted";
shortOverview = item.Kind switch
{
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated}",
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate.ToLocalTime()}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated.ToLocalTime()}",
_ => throw new NotImplementedException(),
};
overview = $"{episode.Path}";
Expand All @@ -560,8 +560,8 @@ private async Task CreateNotification(ExpiredItem item)
title = $"\"{video.Name}\" was deleted";
shortOverview = item.Kind switch
{
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated}",
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate.ToLocalTime()}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated.ToLocalTime()}",
_ => throw new NotImplementedException(),
};
overview = $"{video.Path}";
Expand All @@ -571,8 +571,8 @@ private async Task CreateNotification(ExpiredItem item)
title = $"\"{item.Item.Name}\" was deleted";
shortOverview = item.Kind switch
{
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated}",
ExpiredKind.Played => $"Last played by {item.Data.First().User.Username} at {item.Data.First().LastPlayedDate.ToLocalTime()}",
ExpiredKind.NotPlayed => $"Not played by anyone since {item.Item.DateCreated.ToLocalTime()}",
_ => throw new NotImplementedException(),
};
overview = $"{item.Item.Path}";
Expand Down

0 comments on commit 4347ebd

Please sign in to comment.