I am trying to create a way to store dates, but for any type of custom calendar system a user makes. The user could make a plugin for complex Calendars such as the Gregorian or simple calendars where a user can input a map of “Cycles” to Integer representing the count of cycles in the Cycle before it.
Example:
Year → Seconds (Total Seconds for 1 Solar Orbit)
Month → Days in 1 Month
Day → Hours in 1 Day
Hour → Minutes in 1 Hour
Minute → Seconds in 1 Minute
I was thinking I could use a Curve for Months, so that user can define a curve to set number of months and length of each month in 1 Year. I do not know though, yet, how I can create a system so that a user at runtime can create a custom table, and then save that Table to a SaveGame or Text file.
I was thinking I would need to store time as seconds in a Int64, and then I could easily create a historical “log” for any struct by using a map of Int64->Struct.
As an example, the user can create characters, and lets say each character has a character profile struct that contains the various information relating to behavior, mentality, personality etc., but this can change over time as the character develops, and I want to be able to select the time period to load the correct character profile for that character at that time. Simple, I can take the current world date (depending on the calendar the date is in), convert to world time in seconds, then look up that time on the Character Profile Map getting the Int64 and the CharProfile struct for that time (You would find the closest one not exceeding the date), then you could load the Character Profile that would be relevant.
I was also thinking it might be better to only store changes in the Character Prfile Struct, to keep data compressed and not store redundant information. So Then, I would need to get the latest date in the CharProfile, and load each “timestamp” and add the information from the previous changes to get the final result.
I ran into a problem when dividing Int64, as it does not change it to a float (or Double Float?), and to be able to convert from base seconds to a date using a calendar conversion, I would need to know the remainder yes/no? And with Int64 it returns Int64?
I am at a loss trying to figure out how to Go from a date in Seconds to a Calendar Date
If I take X Seconds, and divide by Y I need the total and remainder so I can convert remainder to the next cycle divisor…