Permalink
Browse files

Fix Year issues

  • Loading branch information...
da3dsoul committed Oct 1, 2018
1 parent 8aee296 commit a9d2201f07cd78f825212d92782aaf924f1275e6
@@ -307,10 +307,14 @@ public List<string> GetAllYears()
var allyears = new HashSet<string>(StringComparer.Ordinal);
foreach (CL_AnimeSeries_User ser in grps)
{
int endyear = ser.AniDBAnime.AniDBAnime.EndYear;
int startyear = ser.AniDBAnime.AniDBAnime.BeginYear;
int endyear = ser.AniDBAnime?.AniDBAnime?.EndYear ?? 0;
int startyear = ser.AniDBAnime?.AniDBAnime?.BeginYear ?? 0;
if (startyear == 0) continue;
if (endyear == 0) endyear = DateTime.Today.Year;
if (startyear != 0)
if (startyear > endyear) endyear = startyear;
if (startyear == endyear)
allyears.Add(startyear.ToString());
else
allyears.UnionWith(Enumerable.Range(startyear,
endyear - startyear + 1)
.Select(a => a.ToString()));
@@ -920,9 +920,16 @@ public void UpdateStats(bool watchedStats, bool missingEpsStats)

int endyear = anime.EndYear;
if (endyear == 0) endyear = DateTime.Today.Year;
if (anime.BeginYear != 0)
int startyear = anime.BeginYear;
if (endyear < startyear) endyear = startyear;
if (startyear != 0)
{
var years = Enumerable.Range(anime.BeginYear, endyear - anime.BeginYear + 1).Where(anime.IsInYear).ToList();
List<int> years;
if (startyear == endyear) years = new List<int> {startyear};
else
years = Enumerable.Range(anime.BeginYear, endyear - anime.BeginYear + 1)
.Where(anime.IsInYear).ToList();

allYears.UnionWith(years);
foreach (int year in years)
foreach (AnimeSeason season in Enum.GetValues(typeof(AnimeSeason)))
@@ -192,11 +192,14 @@ public void Save(SVR_AnimeSeries obj, bool onlyupdatestats)
{
int endyear = obj.Contract?.AniDBAnime?.AniDBAnime?.EndYear ?? 0;
if (endyear == 0) endyear = DateTime.Today.Year;
int startyear = obj.Contract?.AniDBAnime?.AniDBAnime?.BeginYear ?? 0;
if (endyear < startyear) endyear = startyear;
HashSet<int> allyears = null;
if ((obj.Contract?.AniDBAnime?.AniDBAnime?.BeginYear ?? 0) != 0)
if (startyear != 0)
{
allyears = new HashSet<int>(Enumerable.Range(obj.Contract.AniDBAnime.AniDBAnime.BeginYear,
endyear - obj.Contract.AniDBAnime.AniDBAnime.BeginYear + 1));
allyears = startyear == endyear
? new HashSet<int> {startyear}
: new HashSet<int>(Enumerable.Range(startyear, endyear - startyear + 1));
}

//This call will create extra years or tags if the Group have a new year or tag

0 comments on commit a9d2201

Please sign in to comment.