summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Tests/Utilities/SDateTests.cs2
-rw-r--r--src/SMAPI/Utilities/SDate.cs4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/SMAPI.Tests/Utilities/SDateTests.cs b/src/SMAPI.Tests/Utilities/SDateTests.cs
index 1f31168e..642f11f6 100644
--- a/src/SMAPI.Tests/Utilities/SDateTests.cs
+++ b/src/SMAPI.Tests/Utilities/SDateTests.cs
@@ -159,7 +159,7 @@ namespace StardewModdingAPI.Tests.Utilities
[TestCase("15 summer Y1", -28, ExpectedResult = "15 spring Y1")] // negative season transition
[TestCase("15 summer Y2", -28 * 4, ExpectedResult = "15 summer Y1")] // negative year transition
[TestCase("01 spring Y3", -(28 * 7 + 17), ExpectedResult = "12 spring Y1")] // negative year transition
- [TestCase("06 fall Y2", 50, ExpectedResult = "28 winter Y3")] // test for zero-index errors
+ [TestCase("06 fall Y2", 50, ExpectedResult = "28 winter Y2")] // test for zero-index errors
[TestCase("06 fall Y2", 51, ExpectedResult = "01 spring Y3")] // test for zero-index errors
public string AddDays(string dateStr, int addDays)
{
diff --git a/src/SMAPI/Utilities/SDate.cs b/src/SMAPI/Utilities/SDate.cs
index ec54f84a..9ea4f370 100644
--- a/src/SMAPI/Utilities/SDate.cs
+++ b/src/SMAPI/Utilities/SDate.cs
@@ -86,7 +86,7 @@ namespace StardewModdingAPI.Utilities
seasonIndex %= 4;
// get year
- int year = hashCode / (this.Seasons.Length * this.DaysInSeason) + 1;
+ int year = (int)Math.Ceiling(hashCode / (this.Seasons.Length * this.DaysInSeason * 1m));
// create date
return new SDate(day, this.Seasons[seasonIndex], year);
@@ -192,7 +192,7 @@ namespace StardewModdingAPI.Utilities
throw new ArgumentException($"Unknown season '{season}', must be one of [{string.Join(", ", this.Seasons)}].");
if (day < 0 || day > this.DaysInSeason)
throw new ArgumentException($"Invalid day '{day}', must be a value from 1 to {this.DaysInSeason}.");
- if(day == 0 && !(allowDayZero && this.IsDayZero(day, season, year)))
+ if (day == 0 && !(allowDayZero && this.IsDayZero(day, season, year)))
throw new ArgumentException($"Invalid day '{day}', must be a value from 1 to {this.DaysInSeason}.");
if (year < 1)
throw new ArgumentException($"Invalid year '{year}', must be at least 1.");