Serializable DateTime - ManeFunction/ManeTools-Unity GitHub Wiki

UTC DateTime stored as a round-trip ISO 8601 string, plus a start–end range. Inspector fields get a text row and a calendar popup. Those inspectors are Property Drawers, so they own the field; Decorators can still wrap it.

using System;
using Mane.Unity;
using UnityEngine;

public class SeasonWindow : MonoBehaviour
{
    [SerializeField] private SerializableDateTime _opens;
    [SerializeField] private SerializableDateTimeRange _active;
}

SerializableDateTime inspector

SerializableDateTime

  • Stored UTC. Invalid strings read as DateTime.UtcNow.
  • Unspecified DateTimeKind is treated as UTC. Local is converted with ToUniversalTime.
  • Normalize drops seconds and smaller units.
  • Display format yyyy-MM-dd HH:mm (DateTimeFormat); date-only yyyy-MM-dd (DateFormat). Both use the invariant culture. ToString() returns the display format.
DateTime utc = SerializableDateTime.ToUtc(local);
string iso = SerializableDateTime.FormatRoundTrip(utc);
SerializableDateTime.TryParse(iso, out DateTime parsed);

string display = SerializableDateTime.FormatDisplay(utc); // 2026-10-09 14:30
string date = SerializableDateTime.FormatDate(utc);       // 2026-10-09

SerializableDateTimeRange

Constructor swaps bounds if start is after end. Default range is now → a week later. StartString / EndString expose the raw ISO strings.

Calendar popup

The inspector button opens CalendarPopup (Mane.Unity.Editor): month grid, hour/minute sliders, UTC and local labels. Range mode has Start/End toggles; picking a start switches to end.

From editor code:

using Mane.Unity.Editor;

CalendarPopup.Show(DateTime.UtcNow, dt => Debug.Log(dt));
CalendarPopup.ShowRange(range, updated => serializedObject.ApplyModifiedProperties());

SerializableDateTime selector SerializableDateTime range selector