aka Calculating time for a novel
A story needs a timeline, especially if your characters are students/are working, and if the story covers a significant length of time (more than two weeks, at least given my writing style). You need to track the passage of time, you need to know what day of the week it is, and you have to track when the holidays are. It's a rather difficult problem if you actually count the days one by one.
This is one of the problems that I really enjoyed solving while writing. First, I love maths. Secondly, the maths is not complicated - you can always use a spreadsheet or something to do the calculations for you unless you are a masochist (if you are, go ahead and do it manually, but consider yourself warned).
So, first things first - you need a reference date. You need to know the date and the day of the week on that day, and if you're tracking the sun/moon/etc to track festivals (as I am doing), you will need to set these down as well. Basically, you have to start at an arbitrary point.
First up, the length of the year. My current biggest project does not take place on earth, so I had a little flexibility with this, so I went with approximately 372.058 days. If you're based on earth, the length of the year will be 365.25 days. Next up, you have to decide the nominal length of a year. I would recommend rounding it down to the nearest integer - for example, I went with 372 days. Again, if you're based on earth, that's 365 days.
From this, you can calculate the frequency of leap years. For earth, that will be every four years. Yes, that means that the calendar gradually gets out of sync with our actual position relative to the sun until it's effectively reset every leap year on February 29th. To calculate the frequency,it's 1 divided by the difference between the length of the actual year and the nominal year.
For example, for earth: 1 ÷ (365.25-365) = 1 ÷ 0.25 = 4.
For a planet with a 234.345 day long year, it will be 1 ÷ (234.345-234) = 1 ÷ 0.345 = 2.89855.
This translates to a leap year every 3 years (round it up to the nearest integer), but that will not get rid of the offset in this case. To deal with this, you simply have to repeat the process until the remainder is small enough / time periods involved are too long for it to matter. To continue with the previous example, that would give:
1 ÷ (234.345 - (234 + (1/3)) = 85.71429 -> another leap year every 86 years. Note that these two cycles will be independent of each other, so in the years that are a multiple of both 3 and 86 from the first leap year (every 258 years), there will be a double leap year - i.e., you have to add two days to the calendar on those days.
Continuing with this process, we get 1 ÷ (234.345 - (234 + (1/3) + (1/86)) = 25800. At this point, we can safely ignore the rest of the remainder, unless your story spans millions of years.
Isn't the earth pretty neat?
Continuing on, after deciding how long the years will be, you have to decide how the year is divided. How many months are there? How long are the months? Do you have a wacky calendar like the Gregorian calendar? (Seriously, I don't care about the ego of Roman emperors, but have a 28 day month smack in the middle of the year while many other months have 31 days is simply insane. Also, there is simply no rhyme or reason as to how the number of days in a month are decided. It used to drive me insane as a child, and it still does).
Other things you have to decide before proceeding include the resolution of your calendar (seconds, or even shorter? It may be important if you're going to include festivals based on celestial events. Otherwise, days will work quite well), and the number of days in a week if you're going with the year-month-week-day system we use. If not, you can make anything up. If you're based on the earth, you can simply use the existing calendar.
That being done, you have to come up with a program, essentially, to output the day of the week once you input the date. This can be quite complicated, but the calculation can be used if you're going to include the movement of celestial objects, so bear with me.
The most important step, and the first thing you need to do, is to calculate the time elapsed since the reference date. I will use the earth for calculations, because it is both insanely complicated (thanks to humans, the universe made the starting point a lot easier) and familiar to everyone, so there is less information to absorb.
Say the reference point is the first of January, 2010. My computer says it's a Friday. So, armed with that information, we can proceed. Say we want to figure out what day it is on the 17th of September, 2018. We will use days for calculation. So, here are the steps:
Elapsed years = (2018-2010) - 1 = 7 (remember, 2018 is not over yet).
No of leap years = ((2018-2010) - 1)/4 + 1 = 2.75 = 2 (round it down. 1 is added because the starting year is a leap year. I would recommend starting with a leap year, otherwise this calculation will get complicated.)
No of days elapsed in the past years = 7*365 + 1 = 2557.
Elapsed months: January to August (The current month, September, isn't included). You have to specify this because the lengths of the months vary, so you have to add each of them individually. You have to account for February's changing length as well. Since 2018 is a leap year, this gives 31+29+31+30+31+30+31+31=244 days.
Then you add the remaining no of days to the 17th - which is 16 days.
The total is 2556+244+16 = 2817 days.
At least the weeks are consistent here on earth, which makes the next part a lot easier. You simply divide the number of days you obtained by 7 and get the remainder, and map it to the days of the week. The reference day will be 0, so you get
0 = Friday
1 = Saturday
2 = Sunday
3 = Monday
4 = Tuesday
5 = Wednesday
6 = Thursday.
So, you get 2817%7 = 3 ->Monday.
You can try this with any reference date. If you're working backwards from the reference date, there are some changes - the leap year calculation changes, and you have to start counting months and days from the other end, but once you account for those changes, the algorithm, in its basic form, still works.
As I said, you can use a spreadsheet for this calculation - once you're set it up, basically, you just have to enter the date and you'll get all the information you need. For my work, I calculate everything to the second, because track the movements of some celestial objects as well. The basis of this calculation is also the the time stamp mentioned here. I will get to that calculation in another article.
Hope this helps.
Until next time!
No comments:
Post a Comment