Sojour uses Time Units to model any calendar from first principles.
Here are a selection of calendars created using these Time Units (Click the images to see full sized versions – you can do this for all images in this post):
As you can see, the calendar system is pretty flexible!
However, there used to be a limitation with the system. It couldn’t support calendars that roll their days relative to their months. For example in the Western Gregorian calendar, the 1st of February will start on a different day of the week dependent on the year.
Given that Sojour couldn’t model this, it used to cheat and provided the user with the Windows Operating System’s Gregorian Calendar.
But not any more! Sojour can now model rolling calendars too! 😎
I thought the best way to test the new rolling calendars functionality was to build the Western Gregorian Calendar from first principles using only Time Units and Rolling Entities. If I could get Sojour to model this relatively complex calendar, it should be able to model any calendar!
A few months back I had thought I was nearly there. But detailed testing showed that my calendar always seemed to be a day out here or there. Tracking down these issues took a lot of time. But they are now all fixed!
One problem (of many) were the leap years. I had thought they were simple.
Every four years is a leap year, right?
Wrong.
Turns out there are additional rules…
If the year is divisible by 100, then it must also be divisible by 400 to qualify! So 1700 and 1800 would not be leap years, but 1600 would be.
To allow the modelling of this and other rules, I added the concept of leap year rules, which consist of a triggering condition and any number of rules associated with that trigger:
For the moment the system only supports divisor triggers and rules, but it is designed to support any mathematical expression should the need arise.
To model the Gregorian calendar Sojour only needed one trigger and one rule. The trigger is activated when a year is divisible by 100. Once triggered, its associated rule – the year must be divisible by 400 – is then invoked.
I suspect that most gamers will not use this functionality as RPG calendars tend to be relatively simple affairs . However, these rules are incorporated to allow the user to be able to create complex calendars such as the Gregorian one.
Why bother trying to model rolling calendars?
Rolling calendars, or in Sojour’s parlance Rolling Entities, allow for a lot more flexibility and will allow users to create their own custom rolling calendars such as the Golarian one used in the Pathfinder RPG. Without this ability, such calendars would be impossible to create.
How are the rolling days of a month created and modelled in Sojour for the Gregorian calendar?
You need to create a Rolling Entity Group, call it days of the week, add the seven days and then associate that Rolling Entity Group with a Time Unit level:
The screenshot above shows our days of the week Rolling Entity Group. We have also ticked the ‘Override Time Unit?’ option so that these Rolling Entities replace the names of their target Time Units.
If you examine the screen shot closely, you can also see that these Rolling Entities target the third level of Time Units, which in this calendar’s case equate to days (as seen in the tree view on the left).
The ‘Start Year’ and ‘Start Rolling Entity’ fields are simply used to determine how the Rolling Entity Group is synchronised with the main calendar. In this case we are saying that for the start of the year 2024, its first day of the week will be a Monday. Sojour will then automatically calculate all the other days of the week!
Rolling Entity Groups and Rolling Entities are extremely powerful. They aren’t just limited to modelling days of the week. A calendar could have as many of these as required and each of them could be applied in a myriad of different ways.
For example, in the Gregorian Calendar, we could add an additional Rolling Entity Group to model the phases of the moon. These moon phases would then show up on the relevant days!
For the rest of this post I will show you Sojour’s Gregorian calendar from first principles using Time Units and Rolling Entities, along with proof that Sojour’s calculations are correct!
First up, an easy one, today’s date:
So far so good…
Lets try the earliest year that Windows 11 allows its calendar to go – 1924:
Still good!
What about a long way in the future? Say the Year 4765?
Alas, the Windows 11 calendar won’t go that far in the future, so we will have to check our calendar against what the Internet says:
Sojour is still delivering the goods!
What about the crazy leap year rules? Will Sojour show 1600 as a leap year, but 1700 and 1800 as non leap years?
Yes. Yes it does!
As an aside, any Time Unit or group of Time Units can be leap year enabled to allow you to create some truly unique leap years for your calendars. These are already used to great effect in the D&D calendar.
Those leap year screen shots look impressive, but how do I know that the actual days of the week shown are correct? Let’s pick 1700 at random. Here is what the internet says:
All good here too!
How about a crazy early year? Say the year 15 AD?
Sojour is still rocking!
Can we go earlier? Oh yes! But alas I haven’t found an online resource to verify the days of the week for such early dates. However, I am satisfied that the internal mathematics are calculating the days of the week accurately.
Here is 426bc:
As noted above, there is no reliable way to confirm that the calculations for this date are correct, but given that Sojour is using the same calculations as used in the previous date examples, I have no reason to doubt its accuracy.
This post might not seem impressive until you consider that this Gregorian calendar is not using any operating system components for its calculations. Instead, it is using Sojour’s Time Units and Rolling Entities from first principles.
These Time Units and Rolling Entities can be used to create any calendar that you can imagine. I’m pretty certain that there is nothing like this in the software market right now and I’m only just getting started!
Why the blog post?
Firstly I wanted to show you folks that I’m still hard at work!
Secondly, I wanted to celebrate getting over the big development hump – the hard bit – the actual calculations themselves. Everything else should theoretically be a lot simpler to implement (famous last words!).
In terms of the development effort so far, I’m up to 25 code commits and 69 hours and 35 minutes of coding and testing!
Quite a lot of time has been sunk into this. But I think it will be worthwhile as it will provide Sojour with a world class leading calendar model.
There is still a long way to go as there is a lot more that I want to add to version two of the calendars system.
As with all other enhancements, this calendars update will be free of charge for all existing Sojour customers!
Thank you for your patience and have fun!
RobP



























