Repository navigation
Serializable DateTime
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;
public void Use()
{
DateTime utc = _opens; // implicit
_opens = DateTime.UtcNow;
Debug.Log(_active); // "yyyy-MM-dd HH:mm – yyyy-MM-dd HH:mm"
}
}- Stored UTC. Invalid strings read as
DateTime.UtcNow. - Unspecified
DateTimeKindis treated as UTC. Local is converted withToUniversalTime. -
Normalizedrops seconds and smaller units. - Display format
yyyy-MM-dd HH:mm; date-onlyyyyy-MM-dd.
DateTime utc = SerializableDateTime.ToUtc(local);
string iso = SerializableDateTime.FormatRoundTrip(utc);
SerializableDateTime.TryParse(iso, out DateTime parsed);Constructor swaps bounds if start is after end. Default range is now → a week later. StartString / EndString expose the raw ISO strings.
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());Screenshot:
calendar-date.png— single-date popup (grid + time sliders). Host athttps://raw.githubusercontent.com/wiki/ManeFunction/ManeTools-Unity/calendar-date.png.
Screenshot:
calendar-range.png— range mode with Start/End buttons and hover highlight. Host athttps://raw.githubusercontent.com/wiki/ManeFunction/ManeTools-Unity/calendar-range.png.
openupm add com.manefunction.tools-unity