Interface ICalendar
ENGINE: Calendar abstraction for custom date systems.
PATTERN: Engine-Game Separation (Pattern 1)
- ENGINE provides: ICalendar interface + StandardCalendar default
- GAME provides: Custom calendars (Roman AUC, Fantasy 13-month, etc.)
Use Cases:
- Historical games: AD/BC eras, real month names
- Roman games: AUC (Ab Urbe Condita) dating
- Fantasy games: Custom month names, different year lengths
All implementations must be deterministic for multiplayer compatibility.
public interface ICalendar
Properties
DaysPerYear
Total days in a year (for year-based calculations)
int DaysPerYear { get; }
Property Value
- int
HoursPerDay
Hours per day (typically 24)
int HoursPerDay { get; }
Property Value
- int
MonthsPerYear
Number of months in a year
int MonthsPerYear { get; }
Property Value
- int
Methods
ClampToValidDate(int, int, int, int)
Clamp date to valid range for this calendar. Useful when loading saves or setting dates programmatically.
GameTime ClampToValidDate(int year, int month, int day, int hour)
Parameters
yearintmonthintdayinthourint
Returns
FormatDate(GameTime)
Format full date for display. Example: "11 November 1444 AD"
string FormatDate(GameTime time)
Parameters
timeGameTime
Returns
- string
FormatDateCompact(GameTime)
Format compact date for limited UI space. Example: "1444.11.11" or "11 Nov 1444"
string FormatDateCompact(GameTime time)
Parameters
timeGameTime
Returns
- string
FormatYear(int)
Format year with era designation. Examples: "1444 AD", "753 BC", "AUC 507" Year 0 = 1 BC in standard AD/BC system.
string FormatYear(int year)
Parameters
yearint
Returns
- string
GetDaysInMonth(int)
Get days in specified month (1-indexed). Standard calendar returns 30 for all months. Custom calendars can vary (28-31 for realistic, any for fantasy).
int GetDaysInMonth(int month)
Parameters
monthint
Returns
- int
GetMonthAbbreviation(int)
Get abbreviated month name for compact UI. Standard calendar returns "M1", "M2", etc. GAME layer provides real abbreviations ("Jan", "Feb", etc.)
string GetMonthAbbreviation(int month)
Parameters
monthint
Returns
- string
GetMonthName(int)
Get localized month name. Standard calendar returns "Month 1", "Month 2", etc. GAME layer provides real names ("January", "Ianuarius", etc.)
string GetMonthName(int month)
Parameters
monthint
Returns
- string
IsValidDate(int, int, int)
Validate that date components are within calendar bounds. Returns true if month is 1-MonthsPerYear and day is 1-GetDaysInMonth(month).
bool IsValidDate(int year, int month, int day)
Parameters
yearintmonthintdayint
Returns
- bool