diff --git a/src/SMAPI/Utilities/SDate.cs b/src/SMAPI/Utilities/SDate.cs
index 0ab37aa0..301ea9d2 100644
--- a/src/SMAPI/Utilities/SDate.cs
+++ b/src/SMAPI/Utilities/SDate.cs
@@ -29,6 +29,9 @@ namespace StardewModdingAPI.Utilities
/// The season name.
public string Season { get; }
+ /// The season index.
+ public int SeasonIndex { get; }
+
/// The year.
public int Year { get; }
@@ -63,6 +66,20 @@ namespace StardewModdingAPI.Utilities
return new SDate(Game1.dayOfMonth, Game1.currentSeason, Game1.year, allowDayZero: true);
}
+ /// Get the date equivalent to the given WorldDate.
+ /// A date returned from a core game property or method.
+ public static SDate FromWorldDate(WorldDate worldDate)
+ {
+ return new SDate(worldDate.DayOfMonth, worldDate.Season, worldDate.Year, allowDayZero: true);
+ }
+
+ /// Get the date falling the given number of days after 0 spring Y1.
+ /// The number of days since 0 spring Y1.
+ public static SDate FromDaysSinceStart(int daysSinceStart)
+ {
+ return new SDate(0, "spring", 1, allowDayZero: true).AddDays(daysSinceStart);
+ }
+
/// Get a new date with the given number of days added.
/// The number of days to add.
/// Returns the resulting date.
@@ -98,6 +115,18 @@ namespace StardewModdingAPI.Utilities
return $"{this.Day:00} {this.Season} Y{this.Year}";
}
+ /// Get a string representation of the date in the current game locale.
+ public string ToLocaleString()
+ {
+ return this.ToWorldDate().Localize();
+ }
+
+ /// Get the date as an instance of the game's WorldDate class. This is intended for passing to core game methods.
+ public WorldDate ToWorldDate()
+ {
+ return new WorldDate(this.Year, this.Season, this.Day);
+ }
+
/****
** IEquatable
****/
@@ -200,6 +229,7 @@ namespace StardewModdingAPI.Utilities
// initialize
this.Day = day;
this.Season = season;
+ this.SeasonIndex = this.GetSeasonIndex(season);
this.Year = year;
this.DayOfWeek = this.GetDayOfWeek(day);
this.DaysSinceStart = this.GetDaysSinceStart(day, season, year);