Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Modding:Modder Guide/APIs/Utilities
(view source)
Revision as of 02:00, 29 June 2020
385 bytes added
,
02:00, 29 June 2020
→Dates
:
update for newer SMAPI versions
Line 72:
Line 72:
var date = new SDate(28, "spring"); // date in the current year
var date = new SDate(28, "spring"); // date in the current year
var date = new SDate(28, "spring", 2); // date in the given year
var date = new SDate(28, "spring", 2); // date in the given year
+
var date = SDate.From(Game1.Date); // from a game date
</source>
</source>
Line 89:
Line 90:
if (a < b) // true
if (a < b) // true
...
...
+
</source>
+
+
...and get a translated date string:
+
<source lang="c#">
+
var date = new SDate(15, "summer");
+
string message = $"See you on {date.ToLocaleString(withYear: false)}!"; // See you on Summer 15!
</source>
</source>
Line 111:
Line 118:
| <tt>Season</tt>
| <tt>Season</tt>
| The normalised season name.
| The normalised season name.
+
|-
+
| <tt>SeasonIndex</tt>
+
| The zero-based season index recognised by game methods like <tt>Utility.getSeasonNameFromNumber</tt>.
|-
|-
| <tt>Year</tt>
| <tt>Year</tt>
Pathoschild
translators
8,437
edits
Navigation menu
Personal tools
Create account
Log in
Namespaces
Modding
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
Main page
Recent changes
Admin noticeboard
Help Editing
Random page
Official Links
Official Site
Official Forums
Official Merchandise
Discord
Reddit
Tools
Upload file
Special pages
Printable version