diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index 621d4b258..b1fbb6ff2 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -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); diff --git a/src/NzbDrone.Common/Extensions/DateTimeExtensions.cs b/src/NzbDrone.Common/Extensions/DateTimeExtensions.cs index 69e2e5e17..e98e651d0 100644 --- a/src/NzbDrone.Common/Extensions/DateTimeExtensions.cs +++ b/src/NzbDrone.Common/Extensions/DateTimeExtensions.cs @@ -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); } } diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs index f9d80f7a7..35402d475 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs @@ -95,7 +95,7 @@ public IList 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, diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs index 7ad231f42..7fe24166a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs @@ -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(); foreach (var pair in pairs) diff --git a/src/NzbDrone.Core/Indexers/Definitions/NzbIndex.cs b/src/NzbDrone.Core/Indexers/Definitions/NzbIndex.cs index bc23d0c6a..4d882cf4f 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/NzbIndex.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/NzbIndex.cs @@ -1138,8 +1138,6 @@ public IList ParseResponse(IndexerResponse indexerResponse) foreach (var row in jsonContent.Value("results")) { - var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); - var id = row.Value("id"); var details = _settings.BaseUrl + "collection/" + id; @@ -1157,7 +1155,7 @@ public IList ParseResponse(IndexerResponse indexerResponse) DownloadUrl = _settings.BaseUrl + "download/" + id, Title = parsedTitle.Groups["title"].Value, Categories = row.Value("group_ids").SelectMany(g => _categories.MapTrackerCatToNewznab(g.Value())).Distinct().ToList(), - PublishDate = dateTime.AddMilliseconds(row.Value("posted")).ToLocalTime(), + PublishDate = DateTime.UnixEpoch.AddMilliseconds(row.Value("posted")).ToLocalTime(), Size = row.Value("size"), Files = row.Value("file_count") }; diff --git a/src/NzbDrone.Core/Indexers/Definitions/TorrentSyndikat.cs b/src/NzbDrone.Core/Indexers/Definitions/TorrentSyndikat.cs index a986c7291..75ac87684 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TorrentSyndikat.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TorrentSyndikat.cs @@ -226,8 +226,6 @@ public IList ParseResponse(IndexerResponse indexerResponse) foreach (var row in jsonContent.Value("rows")) { - var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); - var id = row.Value("id"); var details = _settings.BaseUrl + "details.php?id=" + id; var seeders = row.Value("seeders"); @@ -243,7 +241,7 @@ public IList ParseResponse(IndexerResponse indexerResponse) DownloadUrl = _settings.BaseUrl + "download.php?id=" + id + "&apikey=" + _settings.ApiKey, Title = row.Value("name"), Categories = _categories.MapTrackerCatToNewznab(row.Value("category").ToString()), - PublishDate = dateTime.AddSeconds(row.Value("added")).ToLocalTime(), + PublishDate = DateTime.UnixEpoch.AddSeconds(row.Value("added")).ToLocalTime(), Size = row.Value("size"), Files = row.Value("numfiles"), Seeders = seeders, diff --git a/src/NzbDrone.Core/Indexers/Definitions/TorrentsCSV.cs b/src/NzbDrone.Core/Indexers/Definitions/TorrentsCSV.cs index 80835a3ec..53b4f8725 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TorrentsCSV.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TorrentsCSV.cs @@ -160,7 +160,7 @@ public IList 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 {