Struct GameDate
A blittable, readonly value representing a fully-resolved date in a custom calendar. Produced on demand by TickToDate(long, CalendarDefinition) and consumed by clocks, schedulers, and rollover events.
Implements
Inherited Members
Namespace: Scylla.Core.Time
Assembly: ScyllaCore.dll
Syntax
[Serializable]
public readonly struct GameDate : IEquatable<GameDate>
Remarks
All fields are integer indices to keep the struct blittable and Burst-compatible. Names (month name, era name, weekday name) are NOT carried on the struct; callers look them up via the originating CalendarDefinition when needed for display.
WeekdayIndex, SeasonIndex, and EraIndex
use -1 to mean "not applicable" (weekday tracking disabled, no season list,
or no matching era), allowing callers to detect "unknown" without comparing against
an arbitrary sentinel.
CalendarHash snapshots CalendarDefinition.GetEntityId() at
the moment the date was produced. Cross-calendar arithmetic must compare hashes
to guard against accidental mixing of dates from incompatible calendars.
Months are zero-based (matches the indexing in CalendarDefinition). Days are 1-based (matches conventional calendar UI).
Constructors
GameDate(int, int, int, int, int, int, int, int, int, int, EntityId)
Initializes a new GameDate. Typically constructed by TickToDate(long, CalendarDefinition) rather than directly.
Declaration
public GameDate(int year, int month, int day, int hour, int minute, int second, int millisecond, int weekdayIndex, int seasonIndex, int eraIndex, EntityId calendarHash)
Parameters
| Type | Name | Description |
|---|---|---|
| int | year | |
| int | month | |
| int | day | |
| int | hour | |
| int | minute | |
| int | second | |
| int | millisecond | |
| int | weekdayIndex | |
| int | seasonIndex | |
| int | eraIndex | |
| EntityId | calendarHash |
Fields
CalendarHash
Snapshot of the source CalendarDefinition.GetEntityId() at construction
time. Session-only: the underlying entity ID is a Unity-assigned value
unique within the current process and is not stable across serialization, domain
reload, or asset re-loading. A GameDate persisted to a save file and
reloaded in a different session will fail the calendar-hash check inside
DateToTick(GameDate, CalendarDefinition). For persistent identification between sessions
prefer storing the canonical millisecond tick value (round-trip safe) and
reconstructing the GameDate on demand via
TickToDate(long, CalendarDefinition).
Declaration
public readonly EntityId CalendarHash
Field Value
| Type | Description |
|---|---|
| EntityId |
Day
1-based day of month.
Declaration
public readonly int Day
Field Value
| Type | Description |
|---|---|
| int |
EraIndex
Zero-based era index, or INDEX_NONE if no era contains this date.
Declaration
public readonly int EraIndex
Field Value
| Type | Description |
|---|---|
| int |
Hour
Hour (0-based).
Declaration
public readonly int Hour
Field Value
| Type | Description |
|---|---|
| int |
INDEX_NONE
Sentinel value for "not applicable" weekday/season/era indices.
Declaration
public const int INDEX_NONE = -1
Field Value
| Type | Description |
|---|---|
| int |
Millisecond
Millisecond (0-based).
Declaration
public readonly int Millisecond
Field Value
| Type | Description |
|---|---|
| int |
Minute
Minute (0-based).
Declaration
public readonly int Minute
Field Value
| Type | Description |
|---|---|
| int |
Month
Zero-based month index into the parent calendar's month list.
Declaration
public readonly int Month
Field Value
| Type | Description |
|---|---|
| int |
SeasonIndex
Zero-based season index, or INDEX_NONE if no season list is defined.
Declaration
public readonly int SeasonIndex
Field Value
| Type | Description |
|---|---|
| int |
Second
Second (0-based).
Declaration
public readonly int Second
Field Value
| Type | Description |
|---|---|
| int |
WeekdayIndex
Zero-based weekday index, or INDEX_NONE if the calendar has no weekdays.
Declaration
public readonly int WeekdayIndex
Field Value
| Type | Description |
|---|---|
| int |
Year
Calendar year, after applying the calendar's epoch-year offset. Negative for dates before the epoch.
Declaration
public readonly int Year
Field Value
| Type | Description |
|---|---|
| int |
Methods
Equals(GameDate)
Compares this date to other field by field, including
CalendarHash. Two dates are equal only when every component
matches AND they originate from the same calendar session.
Declaration
public bool Equals(GameDate other)
Parameters
| Type | Name | Description |
|---|---|---|
| GameDate | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object)
Returns true when obj is a GameDate whose
every field is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
GetHashCode()
Returns a stable hash code based on the date components and CalendarHash. The hash does not incorporate WeekdayIndex, SeasonIndex, or EraIndex because those are derived fields that can be reconstructed from the remaining components.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
ToString()
Returns a compact diagnostic string in the form
GameDate(Y{Year} M{Month} D{Day} HH:mm:ss.mmm).
Intended for logging and debug overlays; not a localized calendar-aware format.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
Operators
operator ==(GameDate, GameDate)
Returns true when all fields of a equal all fields of b.
Declaration
public static bool operator ==(GameDate a, GameDate b)
Parameters
| Type | Name | Description |
|---|---|---|
| GameDate | a | |
| GameDate | b |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(GameDate, GameDate)
Returns true when any field of a differs from the corresponding field of b.
Declaration
public static bool operator !=(GameDate a, GameDate b)
Parameters
| Type | Name | Description |
|---|---|---|
| GameDate | a | |
| GameDate | b |
Returns
| Type | Description |
|---|---|
| bool |