summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Utilities/SDate.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Utilities/SDate.cs')
-rw-r--r--src/StardewModdingAPI/Utilities/SDate.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Utilities/SDate.cs b/src/StardewModdingAPI/Utilities/SDate.cs
index e0613491..d7631598 100644
--- a/src/StardewModdingAPI/Utilities/SDate.cs
+++ b/src/StardewModdingAPI/Utilities/SDate.cs
@@ -32,6 +32,11 @@ namespace StardewModdingAPI.Utilities
/// <summary>The year.</summary>
public int Year { get; }
+#if !SMAPI_1_x
+ /// <summary>The day of week.</summary>
+ public DayOfWeek DayOfWeek { get; }
+#endif
+
/*********
** Public methods
@@ -64,6 +69,9 @@ namespace StardewModdingAPI.Utilities
this.Day = day;
this.Season = season;
this.Year = year;
+#if !SMAPI_1_x
+ this.DayOfWeek = this.GetDayOfWeek();
+#endif
}
/// <summary>Get the current in-game date.</summary>
@@ -198,6 +206,30 @@ namespace StardewModdingAPI.Utilities
/*********
** Private methods
*********/
+ /// <summary>Get the day of week for the current date.</summary>
+ private DayOfWeek GetDayOfWeek()
+ {
+ switch (this.Day % 7)
+ {
+ case 0:
+ return DayOfWeek.Sunday;
+ case 1:
+ return DayOfWeek.Monday;
+ case 2:
+ return DayOfWeek.Tuesday;
+ case 3:
+ return DayOfWeek.Wednesday;
+ case 4:
+ return DayOfWeek.Thursday;
+ case 5:
+ return DayOfWeek.Friday;
+ case 6:
+ return DayOfWeek.Saturday;
+ default:
+ return 0;
+ }
+ }
+
/// <summary>Get the current season index.</summary>
/// <exception cref="InvalidOperationException">The current season wasn't recognised.</exception>
private int GetSeasonIndex()