As I was looking into solutions for another question, I found myself wondering whether it was possible to use .NET's Calendar
class to implement a calendar that wasn't based on Earthly conventions.
For instance, Mars' day is about 2.7% longer than a day here on Earth:
A convention used by spacecraft lander projects to date has been to keep track of local solar time using a 24 hour "Mars clock" on which the hours, minutes and seconds are 2.7% longer than their standard (Earth) durations.
Is there any good way to implement a MarsCalendar
such that the length of a second is different from the standard GregorianCalendar
, and thus be able to use DateTime
objects based on it for all the standard AddDays()
, AddHours()
, etc. functions? (Note: Ideally, a solution - if one exists - would be applicable to any form of planetary object for which it is possible to define both "1 day" and "1 year" of consistent lengths. Mars makes for a great example, though)
There are several non-Gregorian calendar classes derived from System.Globalization.Calendar
within the Globalization namespace (i.e. JapaneseCalendar
). You should be able to implement your own. I'd whip up a sample, but there are 16 abstract methods in the Calendar class...
You might even be able to simply derive your class from GregorianCalendar
and just override the GetMilliseconds(DateTime)
method, returning the base's return value multiplied by 1.027d
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With