Class CalendarDefinition
A fully data-driven calendar specification. Designers create one of these as a UnityEngine.ScriptableObject asset, populate the lists of months, seasons, weekdays, and eras, and reference it from a ClockDefinition. The calendar is read by CalendarMath when converting tick counts to GameDate values and back.
Inherited Members
Namespace: Scylla.Core.Time
Assembly: ScyllaCore.dll
Syntax
[ScyllaCreateAsset("Core/Time/Calendar Definition", FileName = "Calendar Definition")]
public sealed class CalendarDefinition : ScriptableObject
Remarks
The same CalendarDefinition can be referenced by multiple clocks. All clocks sharing a calendar produce dates with the same CalendarHash, allowing arithmetic between their dates; clocks using different calendars produce dates with mismatched hashes that CalendarMath rejects.
Built-in presets (a Gregorian variant) ship under Resources/Calendars/.
Game projects are free to author additional calendars (Skyrim-style, Dwarf Fortress
12 x 28, planet-specific calendars, etc.) entirely as data with no code.
Fields
DEFAULT_HOURS_PER_DAY
Default hours-per-day matching the Earth/Gregorian 24-hour day.
Declaration
public const int DEFAULT_HOURS_PER_DAY = 24
Field Value
| Type | Description |
|---|---|
| int |
DEFAULT_MILLISECONDS_PER_SECOND
Default milliseconds-per-second matching the Earth SI definition (1000 ms/s).
Declaration
public const int DEFAULT_MILLISECONDS_PER_SECOND = 1000
Field Value
| Type | Description |
|---|---|
| int |
DEFAULT_MINUTES_PER_HOUR
Default minutes-per-hour matching the Earth/Gregorian 60-minute hour.
Declaration
public const int DEFAULT_MINUTES_PER_HOUR = 60
Field Value
| Type | Description |
|---|---|
| int |
DEFAULT_SECONDS_PER_MINUTE
Default seconds-per-minute matching the Earth/Gregorian 60-second minute.
Declaration
public const int DEFAULT_SECONDS_PER_MINUTE = 60
Field Value
| Type | Description |
|---|---|
| int |
Properties
EpochName
Display name for the epoch (e.g., "4E").
Declaration
public string EpochName { get; }
Property Value
| Type | Description |
|---|---|
| string |
EpochYearOffset
Year offset applied at tick 0.
Declaration
public int EpochYearOffset { get; }
Property Value
| Type | Description |
|---|---|
| int |
Eras
Read-only view of the era list. Empty means no era resolution.
Declaration
public IReadOnlyList<EraDefinition> Eras { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<EraDefinition> |
FirstWeekdayIndex
Zero-based index into Weekdays of the weekday considered the first day of a week for HUD/UI purposes (e.g., 0 for Sunday-first US convention, 1 for Monday-first ISO 8601). Clamped to a valid index when the weekday list is non-empty; returns 0 when the weekday list is empty.
Declaration
public int FirstWeekdayIndex { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
This is a display preference: it does NOT influence
ResolveWeekdayIndex(long, CalendarDefinition). The weekday at tick 0 is always the
entry at index 0 in the Weekdays list. Consumers laying out a calendar
widget should compute display column with
(weekdayIndex - FirstWeekdayIndex + Weekdays.Count) % Weekdays.Count.
HoursPerDay
Hours in one day cycle.
Declaration
public int HoursPerDay { get; }
Property Value
| Type | Description |
|---|---|
| int |
LeapRule
Leap-year rule.
Declaration
public LeapYearRule LeapRule { get; }
Property Value
| Type | Description |
|---|---|
| LeapYearRule |
MillisecondsPerSecond
Milliseconds in one second.
Declaration
public int MillisecondsPerSecond { get; }
Property Value
| Type | Description |
|---|---|
| int |
MinutesPerHour
Minutes in one hour.
Declaration
public int MinutesPerHour { get; }
Property Value
| Type | Description |
|---|---|
| int |
Months
Read-only view of the month list.
Declaration
public IReadOnlyList<MonthDefinition> Months { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<MonthDefinition> |
Seasons
Read-only view of the season list.
Declaration
public IReadOnlyList<SeasonDefinition> Seasons { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<SeasonDefinition> |
SecondsPerMinute
Seconds in one minute.
Declaration
public int SecondsPerMinute { get; }
Property Value
| Type | Description |
|---|---|
| int |
Weekdays
Read-only view of the weekday list. Empty disables weekday tracking.
Declaration
public IReadOnlyList<WeekdayDefinition> Weekdays { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<WeekdayDefinition> |
Methods
GetDaysInMonth(int, int)
Returns the number of days in the given monthIndex for
year, applying the leap rule when relevant. Out-of-range
monthIndex values throw ArgumentOutOfRangeException
so off-by-one bugs surface immediately rather than silently wrapping to a different
month and producing wrong tick counts.
Declaration
public int GetDaysInMonth(int year, int monthIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | year | |
| int | monthIndex |
Returns
| Type | Description |
|---|---|
| int |
GetDaysInYear(int)
Returns the total number of days in year, summing
GetDaysInMonth(int, int) across the month list.
Declaration
public int GetDaysInYear(int year)
Parameters
| Type | Name | Description |
|---|---|---|
| int | year |
Returns
| Type | Description |
|---|---|
| int |