diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-08-21 16:39:21 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-08-21 16:39:21 -0400 |
commit | 8ba54a682fd7de3756b6ddd262b232cf40d23ea0 (patch) | |
tree | 7e44d53b733d95b05b232da46306a0d3d57e9231 /src/StardewModdingAPI/Utilities/SDate.cs | |
parent | 674ad0d90f8780130a5fcefb3869acfe2315df2a (diff) | |
parent | eea5100acea0bceaf440f9d1bd50ee2b24cf8ebc (diff) | |
download | SMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.tar.gz SMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.tar.bz2 SMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Utilities/SDate.cs')
-rw-r--r-- | src/StardewModdingAPI/Utilities/SDate.cs | 32 |
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() |