summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicholas Johnson <johnson.nicholas.h@gmail.com>2017-08-01 12:27:02 -0700
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2017-08-01 15:27:02 -0400
commit4ff15b9da965c541c40a11a79cb521cad744900c (patch)
tree1ce9c25aaf1fb4cc4730d2d9fed9f8e78cb3e89e /src
parent3599daee459ee27bfe9374c675eb71d086fcfd81 (diff)
downloadSMAPI-4ff15b9da965c541c40a11a79cb521cad744900c.tar.gz
SMAPI-4ff15b9da965c541c40a11a79cb521cad744900c.tar.bz2
SMAPI-4ff15b9da965c541c40a11a79cb521cad744900c.zip
add weekday property to SDate (#339)
Diffstat (limited to 'src')
-rw-r--r--src/StardewModdingAPI/Utilities/SDate.cs32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Utilities/SDate.cs b/src/StardewModdingAPI/Utilities/SDate.cs
index e0613491..f6650231 100644
--- a/src/StardewModdingAPI/Utilities/SDate.cs
+++ b/src/StardewModdingAPI/Utilities/SDate.cs
@@ -19,6 +19,8 @@ namespace StardewModdingAPI.Utilities
/// <summary>The number of days in a season.</summary>
private readonly int DaysInSeason = 28;
+ /// <summary>The Day of the Week this date has</summary>
+ public DayOfWeek Weekday;
/*********
** Accessors
@@ -32,7 +34,6 @@ namespace StardewModdingAPI.Utilities
/// <summary>The year.</summary>
public int Year { get; }
-
/*********
** Public methods
*********/
@@ -64,6 +65,8 @@ namespace StardewModdingAPI.Utilities
this.Day = day;
this.Season = season;
this.Year = year;
+
+ this.Weekday = GetDayOfWeek();
}
/// <summary>Get the current in-game date.</summary>
@@ -114,6 +117,33 @@ namespace StardewModdingAPI.Utilities
return $"{this.Day:00} {this.Season} Y{this.Year}";
}
+ /// <summary>
+ /// This gets the day of the week from the date
+ /// </summary>
+ /// <returns>A constant describing the day</returns>
+ 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;
+ }
+ }
+
/****
** IEquatable
****/