An Ermarianese year is 27262760 seconds, or 0.8639224726139584 of an Earth year.
This is the actual length of an Ermarianese solar year, synchronized with the calendar
to within 1e-8 divided by the average year on Earth including leapyears.
The maximum deviation of the calendar date from the solar date is about half a day
in either direction, before the leapyear correction is applied.
We can therefore assume that with E = fractional year on Ermarian and T = year on Earth,
the formula E = T / 0.8639225 + x is always correct to within <.01.
(NOTE: All existing sources on the offset x incorrectly ignore leapyears on Earth.)
Now we need to determine x.
A forum post states:
> we'll overtake them in 2519.
The statement might have multiple interpretations, but the most sensible one is this:
- 2519 New Years will be celebrated on Earth before it is celebrated on Ermarian.
- 2520 New Years will be celebrated on Ermarian first.
This means that the point between E < T and E > T will have both E and T within [2519,2520].
Mathematically, it implies:
2519.0 / 0.8639225 + x < 2519.0
2520.0 / 0.8639225 + x > 2520.0
2520.0 - 2520.0 / 0.8639225 < x < 2519.0 - 2519.0 / 0.8639225
-396.9283124 < x < -396.7708012
Which is a fairly tight window! The margin for this offset is less than 50 full Earth days,
and just over 44 Ermarianese ones. That's already enough to estimate the seasonal correspondence for
any given year.
Moreover, it's the closest we can get from existing information,
since all other sources incorrectly set the Earth year to 365 instead of 365.2425 Earth days,
and are therefore off by as much as a year.
Let us therefore now and forevermore fix the offset at -396.848217494 Ermarianese years, which
is a randomly generated (no really) value in this window.
2520-01-01 00:00:00 UTC corresponds to UNIX T=17356287600. According to our offset, the
Ermarianese year is 2520.08009494, corresponding to day 23 of the year (1 offset, remember),
and rel 27957 of the day.
The Ermarianese date corresponding to T, accordingly, is [09D8-EVE-17-6d.35] or 2520-EVE-23 06:13:053
Conveniently, the Ermarianese calendar ALSO has a timestamp format, which is the number of rels (technically
millirels, but whatever) since [0600-EVE-01 00.00], or 1536-EVE-01 00:00:000.
To actually derive the timestamp corresponding to T, of course, we need to take into account leapyears.
Every year divisible by 7 but not 350 is a leapyear. (Also, the first leapyear after a year divisible by 10000
is a double-leapyear, but we can safely ignore this rule for the next 7000 years or so.)
There are 984 years between 1536 and 2520. The first leapyear is in 1540 and the last one is, conveniently,
in 2520 - though it is obviously not included, because the day is added to Radiane, and it is only Evermoon 23.
The three anti-leapyears (multiples of 350) are 1750, 2100 and 2450.
Therefore, there are exactly 137 leapyears between 1536 and 2520.
This yields a total difference of 280*984+137+22 days, plus 27957 rels, for a total timestamp of 18066926901.
So we know that Ermarianese time 18066926901 (rels) corresponds to Earth time 17356287600 (seconds).
And now we can completely ignore planets and years and days, because the seconds/rel value
is fixed. It's a precise rational number, even; 13657516140 / 9192631770 (because periods of Cs-133 and
SI and stuff).
So we can definitively state that a UNIX timestamp T can be converted to an Ermarianese timestamp E like this:
E = T * (9192631770 / 13657516140) + 6384717694
This leaves the relatively simple task of implementing an algorithm that converts Ermarianese dates to
Ermarianese timestamps and vice versa.
DAY = E // 65536 -- rels to full days
DAY -= 280*214+29 -- shift to 1750, the first anti-leapyear
DAY -= 35*4 -- shift to Empire 1, the first day after the Radiane 35.
ANTI = DAY // 98050 + 1 -- anti-leapyears passed over, including 1750 itself.
LEAP = DAY // 1961 -- semi-leapyears passed over
YEAR = (DAY - LEAP + ANTI) // 280 -- full years since 1540-EMP-1.
YEAR += 1540
YEARDAY = (DAY - LEAP + ANTI) % 280 -- day of the year
YEARDAY += 35*4+1
MONTH = YEARDAY // 35 + 1 -- month of the year
MONTHDAY = YEARDAY % 35 + 1 -- day of the month
TIME = E % 65536
return [YEAR, MONTH, MONTHDAY, TIME]