Convert between different calendars (Gregorian/Julian) in WinRT… Windows.Globalization.Calendar?
I am looking for a way to convert between the Gregorian and Julian calendars in WinRT.
Usually, I would use DateTime.FromOADate and DateTime.ToOADate, but these methods aren't available. So I found the Windows.Globalization.Calendar type which seems to have some sort of ChangeCalendarSystem method. But who knows how this type works? The method seems to accept something nice, Windows.Globalization.CalendarIdentifiers.Julian, but now I'm beginning to wonder...
And of course, no real docs, no blogs, no nothing - or maybe I'm looking wrong ;)
Can anyone help shed some light on how the type works in this regard, or maybe point me towards the correct types?
Windows.Globalization.Calendar is the correct thing to use. If you want to convert from Gregorian to Julian, set the calendar system to Gregorian by using ChangeCalendarSystem then set the constituents (starting with largest first: year, month, day,...) to their Gregorian values. Finally, change the calendar system to Julian and then get the constituents.
If you are just wanting to format the value in a different calendar system, you can use the DateTimeFormatter created with the particular calendar system.