Add calendar and date/time system#228
Open
The3dVehicleguy wants to merge 4 commits intoPanosK92:masterfrom
Open
Add calendar and date/time system#228The3dVehicleguy wants to merge 4 commits intoPanosK92:masterfrom
The3dVehicleguy wants to merge 4 commits intoPanosK92:masterfrom
Conversation
- Introduced Calendar, CustomCalendar, and DateTime classes for flexible date/time handling, including leap year logic, custom calendars, and time-of-day management. - Refactored world time logic to use DateTime. - Exposed calendar functions to Lua scripting. Improved path normalization and added robust validation and error handling.
There was a problem hiding this comment.
Pull request overview
Adds a runtime calendar/date-time layer (with custom calendar support) and exposes calendar/time queries to Lua via the World table, enabling editor/UI features that depend on date and time-of-day.
Changes:
- Introduces
Calendar(singleton) with date calculations, naming utilities, and “current date” accessors. - Adds
CustomCalendarto override month/day/season/day-cycle naming, month lengths, and leap-year rules. - Adds
DateTimewrapper for time-of-day access and updatesWorldLua bindings to expose calendar functions.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| source/runtime/World/World.cpp | Switches to std::ranges::replace, routes time-of-day through DateTime, and exposes calendar functions to Lua. |
| source/runtime/World/Time/DateTime.h | Declares a small static DateTime API (time-of-day + validation). |
| source/runtime/World/Time/DateTime.cpp | Implements DateTime by delegating to the existing world_time state. |
| source/runtime/World/Time/Calendar.h | Declares the Calendar singleton API and overridable implementation hooks. |
| source/runtime/World/Time/Calendar.cpp | Implements Gregorian-like calendar utilities and “current date” queries. |
| source/runtime/World/Time/CustomCalendar.h | Declares CustomCalendar overrides and customization setters. |
| source/runtime/World/Time/CustomCalendar.cpp | Implements override logic using custom vectors/functions with fallbacks to Calendar. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Move TimeZoneDbEntry definition to headers. - Convert lookup helpers to TimeZone class static methods. - Update TimeZone.cpp to use new Find* methods. - Modernize string handling with std::erase_if and std::ranges::transform. - Improve modularity and reduce code duplication in DB access.
MrDrElliot
reviewed
Mar 1, 2026
Collaborator
MrDrElliot
left a comment
There was a problem hiding this comment.
Nice! Just a few small suggestions
The3dVehicleguy
added a commit
to The3dVehicleguy/SpartanEngine
that referenced
this pull request
Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Created a calendar and date/time system for the Spartan, including the ability to create a customizable calendar class and utility methods for date and time calculations. This will allow user-defined calendar systems, supporting features like leap years, custom month and day names, and flexible time calculations. I also exposed calendar functions to Lua scripting.
Note
This pull request is the pretext for my UI refactor progress. These functions will allow me to add to the Spartan editor a more interactive and visual time of day/sun and moon cycle UI.
The most important changes are:
Core Calendar System Implementation:
Calendarclass (Calendar.h,Calendar.cpp) with singleton management, date/time calculation utilities (days in month/year, leap year detection, current date retrieval, etc.), and support for both standard and custom calendars. The implementation includes detailed methods for getting names of months, days, seasons, and day cycles, as well as validation and conversion functions. [1] [2]Custom Calendar Support:
CustomCalendarclass (CustomCalendar.h,CustomCalendar.cpp) that extendsCalendarand allows users to define custom month/day/season names, month lengths, leap year rules, and day cycle names. The class overrides relevant methods to use custom data if provided, falling back to the standard calendar otherwise. [1] [2]DateTime Utility Enhancements:
DateTimeclass (DateTime.cpp) with static methods for getting and setting the time of day, as well as validating time values (hours, minutes, seconds). This provides a simple interface for time-of-day management within the engine.Extensibility and Safety: