So in the Chinese / Japanese / Vietnamese Calendar. They use the Sexagenary Cycle for Year, Month, Day, and Hour. Which is a 60 Mix Combination of Hn (Heavenly Stems H1 (Jai / Yang Wood) - H10 (Gui / Yin Water)) and En (Earthly Branch E1 (Rat / Zi) - E12 (Pig / Hai).
The question is, how to set it up so that when a date earlier than H1-E1 it finds the right Combo, and past H10 - E12, it finds the right Combo. So that after setting a date as the starting one. And a Year, Month, Day, and / or Hour is selected. It finds the right one regardless of selection.
Or would I have to do each Year, Month, Day, and Hour individually. Rather than an autogen code?
This is an interesting question! I did some digging after reading this post and found a great wiki article which explains the mathematics behind the system but there are a number of special cases. Im wondering what your use case is, if you want something thats general purpose for any date or if you had a specific date range in mind.
My first thought was to suggest a look up table but depending on the use case it might not be the best option but it would probably be the easiest to implement. Calculating a date in the sexagenary cycle doesnt seem to be particularly computationally heavy but it depends on the immediacy and the number of results required.
The main reason I ask about date range is because the Gregorian calendar hasnt always been what we’ve used but if your date ranges are entirely within the Gregorian (or Julian) calendars then you can save yourself some added work.
Thinking about limiting it to Feb 12, 1204 AD (H1-E1 Year) - 4024 AD (H1-E1 Year)
What we’re planning is mixing Astrological Systems (Sexegenary, Kabbalah (Day of the Month / Astrology Sign + Sun Sign Month) + Vedic Astrology + Lunar Mansions + Tzolkin (Mayan Astrology)
To determine:
Stats,
Skills,
Perma Buffs + Debuffs.
Level Hardness.
Job / Class choices.
By using the Combo Effects used in Bazi, Zi Wei Dou Shu, Pachang, and Kabbalah. To set those up. (Think it’d be an interesting way to use Astrology / Birth Dates. Since a lot of RPGs used to use them, for IG birth dates, or for “relationship compatibility”, but it’d be interesting to use those things to add unique twists for a character depending on IRL / IG birth dates (As well as introducing a Reincarnation System, for X amounts of IG Deaths.)
Ive seem to have made the assumption that you wanted to convert dates to the Gregorian calendar. Which you might do for Vedic Astrology but your question seems to be more about wrapping dates.
One method would be to use an Array of FText for all 60 combinations rather than separate Arrays for Heaven and Earth.
If you use your starting pont of 1204AD, lets say the year 1425AD
We can say its the tail end of Water Rabbit at index 40, 40 years out of the 60 year cycle. You dont actually need to wrap the dates using this method since we are multiplying the cycle by the remainder. With extra data like month/day/time it can be narrowed down, processing the remainder further.
There is a node called Percent used for floats, its actually the Modulo operator. Its often forgotten about when discussing order of operations so keep in mind it happens on the same level as Multiplication and Division
I made New Vars default value 3.6833333 and the print returned 0.6833333! Another property of the modulo operator is checking for odd or even by comparing against 2 which might come in handy if youre using the Ying and Yang.
Edit: Which reminds me, you may want to start your array at 1 and go through to 60 rather than 0 to 59 just so it lines up with existing lookup charts.
You can just use pink Text type as is, it allows the use of unicode as well as localising for different languages. It depends on your needs as to which character set you want to use, for example if you want them all in Chinese you can set those as default or the English conversion. If you need the system to be based on the birthplace of the character that might be more tricky but it should be possible to force the localisation to display a specific translation. The main issue there is if you want the English conversion for multiple sets like Chinese & Vietnamese which have slight variations for names in the cycle. In which case you would have multiple FText arrays with the appropriate conversions to English.