mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
fix (technical): Improved some of the date time parsing handling
This commit is contained in:
parent
f858c88433
commit
20bbe92114
4 changed files with 46 additions and 8 deletions
|
@ -106,11 +106,17 @@ namespace Ombi.Core.Engine
|
|||
SeasonNumber = e.season,
|
||||
Episodes = new List<EpisodeRequests>()
|
||||
};
|
||||
var hasAirDate = e.airstamp.HasValue();
|
||||
var airDate = DateTime.MinValue;
|
||||
if (hasAirDate)
|
||||
{
|
||||
hasAirDate = DateTime.TryParse(e.airdate, out airDate);
|
||||
}
|
||||
newSeason.Episodes.Add(new EpisodeRequests
|
||||
{
|
||||
Url = e.url.ToHttpsUrl(),
|
||||
Title = e.name,
|
||||
AirDate = e.airstamp.HasValue() ? DateTime.Parse(e.airstamp) : DateTime.MinValue,
|
||||
AirDate = airDate,
|
||||
EpisodeNumber = e.number,
|
||||
|
||||
});
|
||||
|
@ -118,12 +124,18 @@ namespace Ombi.Core.Engine
|
|||
}
|
||||
else
|
||||
{
|
||||
var hasAirDate = e.airstamp.HasValue();
|
||||
var airDate = DateTime.MinValue;
|
||||
if (hasAirDate)
|
||||
{
|
||||
hasAirDate = DateTime.TryParse(e.airdate, out airDate);
|
||||
}
|
||||
// We already have the season, so just add the episode
|
||||
season.Episodes.Add(new EpisodeRequests
|
||||
{
|
||||
Url = e.url.ToHttpsUrl(),
|
||||
Title = e.name,
|
||||
AirDate = e.airstamp.HasValue() ? DateTime.Parse(e.airstamp) : DateTime.MinValue,
|
||||
AirDate = airDate,
|
||||
EpisodeNumber = e.number,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -272,11 +272,17 @@ namespace Ombi.Core.Engine.V2
|
|||
Overview = tvSeason.overview,
|
||||
Episodes = new List<EpisodeRequests>()
|
||||
};
|
||||
var hasAirDate = episode.air_date.HasValue();
|
||||
var airDate = DateTime.MinValue;
|
||||
if (hasAirDate)
|
||||
{
|
||||
DateTime.TryParse(episode.air_date, out airDate);
|
||||
}
|
||||
newSeason.Episodes.Add(new EpisodeRequests
|
||||
{
|
||||
//Url = episode...ToHttpsUrl(),
|
||||
Title = episode.name,
|
||||
AirDate = episode.air_date.HasValue() ? DateTime.Parse(episode.air_date) : DateTime.MinValue,
|
||||
AirDate = airDate,
|
||||
EpisodeNumber = episode.episode_number,
|
||||
|
||||
});
|
||||
|
@ -284,12 +290,18 @@ namespace Ombi.Core.Engine.V2
|
|||
}
|
||||
else
|
||||
{
|
||||
var hasAirDate = episode.air_date.HasValue();
|
||||
var airDate = DateTime.MinValue;
|
||||
if (hasAirDate)
|
||||
{
|
||||
DateTime.TryParse(episode.air_date, out airDate);
|
||||
}
|
||||
// We already have the season, so just add the episode
|
||||
season.Episodes.Add(new EpisodeRequests
|
||||
{
|
||||
//Url = e.url.ToHttpsUrl(),
|
||||
Title = episode.name,
|
||||
AirDate = episode.air_date.HasValue() ? DateTime.Parse(episode.air_date) : DateTime.MinValue,
|
||||
AirDate = airDate,
|
||||
EpisodeNumber = episode.episode_number,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -261,9 +261,16 @@ namespace Ombi.Core.Helpers
|
|||
return this;
|
||||
}
|
||||
|
||||
private DateTime FormatDate(string date)
|
||||
private static DateTime FormatDate(string date)
|
||||
{
|
||||
return string.IsNullOrEmpty(date) ? DateTime.MinValue : DateTime.Parse(date);
|
||||
if (date.HasValue())
|
||||
{
|
||||
if (DateTime.TryParse(date, out var d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -255,9 +255,16 @@ namespace Ombi.Core.Helpers
|
|||
return this;
|
||||
}
|
||||
|
||||
private DateTime FormatDate(string date)
|
||||
private static DateTime FormatDate(string date)
|
||||
{
|
||||
return string.IsNullOrEmpty(date) ? DateTime.MinValue : DateTime.Parse(date);
|
||||
if (date.HasValue())
|
||||
{
|
||||
if (DateTime.TryParse(date, out var d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue