mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-07 12:10:20 +02:00
refactor: use DateTime.UnixEpoch across remaining indexers
This commit is contained in:
parent
34cb4e511e
commit
ce31fe4a32
7 changed files with 9 additions and 14 deletions
|
|
@ -350,9 +350,9 @@ public void FolderSetLastWriteTime(string path, DateTime dateTime)
|
|||
{
|
||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||
|
||||
if (dateTime.Before(DateTimeExtensions.Epoch))
|
||||
if (dateTime.Before(DateTime.UnixEpoch))
|
||||
{
|
||||
dateTime = DateTimeExtensions.Epoch;
|
||||
dateTime = DateTime.UnixEpoch;
|
||||
}
|
||||
|
||||
Directory.SetLastWriteTimeUtc(path, dateTime);
|
||||
|
|
@ -362,9 +362,9 @@ public void FileSetLastWriteTime(string path, DateTime dateTime)
|
|||
{
|
||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||
|
||||
if (dateTime.Before(DateTimeExtensions.Epoch))
|
||||
if (dateTime.Before(DateTime.UnixEpoch))
|
||||
{
|
||||
dateTime = DateTimeExtensions.Epoch;
|
||||
dateTime = DateTime.UnixEpoch;
|
||||
}
|
||||
|
||||
File.SetLastWriteTime(path, dateTime);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,5 @@ public static DateTime StartOfDay(this DateTime date)
|
|||
return new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
Grabs = torrent.Snatched,
|
||||
Seeders = torrent.Seeders,
|
||||
Peers = torrent.Leechers + torrent.Seeders,
|
||||
PublishDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).ToUniversalTime().AddSeconds(torrent.Time),
|
||||
PublishDate = DateTime.UnixEpoch.AddSeconds(torrent.Time),
|
||||
Origin = torrent.Origin,
|
||||
Source = torrent.Source,
|
||||
Container = torrent.Container,
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ public async Task DoLogin()
|
|||
var enctype = form.GetAttribute("enctype");
|
||||
if (enctype == "multipart/form-data")
|
||||
{
|
||||
var boundary = "---------------------------" + DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString().Replace(".", "");
|
||||
var boundary = "---------------------------" + (DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds.ToString().Replace(".", "");
|
||||
var bodyParts = new List<string>();
|
||||
|
||||
foreach (var pair in pairs)
|
||||
|
|
|
|||
|
|
@ -1138,8 +1138,6 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
|
||||
foreach (var row in jsonContent.Value<JArray>("results"))
|
||||
{
|
||||
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
var id = row.Value<string>("id");
|
||||
var details = _settings.BaseUrl + "collection/" + id;
|
||||
|
||||
|
|
@ -1157,7 +1155,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
DownloadUrl = _settings.BaseUrl + "download/" + id,
|
||||
Title = parsedTitle.Groups["title"].Value,
|
||||
Categories = row.Value<JArray>("group_ids").SelectMany(g => _categories.MapTrackerCatToNewznab(g.Value<string>())).Distinct().ToList(),
|
||||
PublishDate = dateTime.AddMilliseconds(row.Value<long>("posted")).ToLocalTime(),
|
||||
PublishDate = DateTime.UnixEpoch.AddMilliseconds(row.Value<long>("posted")).ToLocalTime(),
|
||||
Size = row.Value<long>("size"),
|
||||
Files = row.Value<int>("file_count")
|
||||
};
|
||||
|
|
|
|||
|
|
@ -226,8 +226,6 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
|
||||
foreach (var row in jsonContent.Value<JArray>("rows"))
|
||||
{
|
||||
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
var id = row.Value<string>("id");
|
||||
var details = _settings.BaseUrl + "details.php?id=" + id;
|
||||
var seeders = row.Value<int>("seeders");
|
||||
|
|
@ -243,7 +241,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
DownloadUrl = _settings.BaseUrl + "download.php?id=" + id + "&apikey=" + _settings.ApiKey,
|
||||
Title = row.Value<string>("name"),
|
||||
Categories = _categories.MapTrackerCatToNewznab(row.Value<int>("category").ToString()),
|
||||
PublishDate = dateTime.AddSeconds(row.Value<long>("added")).ToLocalTime(),
|
||||
PublishDate = DateTime.UnixEpoch.AddSeconds(row.Value<long>("added")).ToLocalTime(),
|
||||
Size = row.Value<long>("size"),
|
||||
Files = row.Value<int>("numfiles"),
|
||||
Seeders = seeders,
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
var seeders = torrent.Seeders ?? 0;
|
||||
var leechers = torrent.Leechers ?? 0;
|
||||
var grabs = torrent.Completed ?? 0;
|
||||
var publishDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(torrent.Created);
|
||||
var publishDate = DateTime.UnixEpoch.AddSeconds(torrent.Created);
|
||||
|
||||
var release = new TorrentInfo
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue