No February 30th, 1712 in .NET's Swedish calendar?

At this wonderful talk about how weirdness in real life data reflects on computer data types, Jon Skeet tells that February had 30 days in Sweden in 1712 in a weird attempt to manage leap years while adapting to the Gregorian calendar (more on this in Wikipedia). Out of pure curiosity I opened LINQPad and wrote the following:

var date=new DateTime(1712,2,29,CultureInfo.GetCultureInfo("sv-SE").Calendar);
date.AddDays(1).Dump();

I was expecting to see an amazing February 30th but this just yields a boring March 1st. Thinking twice about it, the .NET DateTime class probably doesn't support instances with month=2 and day=30 whatsoever... but anyway, I would like to know: doesn't the .NET's Swedish calendar implement the February 30th 1712 date? Or it actually does but my test is incorrect?

Jon Skeet
people
quotationmark

Basically .NET calendar code doesn't support cutovers between the Gregorian calendar and the Julian calendar... and even if it did, I wouldn't really expect it to support the oddities of the Swedish situation, which didn't follow either of them. Bear in mind that even in "normal" cases, the cutover happened at different times in different cultures. There are plenty of other oddities around historical calendars, too - see the Noda Time trivia page for some examples. I'm particularly fond of the British calendar doing weird things around 1735.

Cutovers are very hard to model, as you end up with gaps which make all kinds of code just blow up. You either end up with an incredibly unwieldy API which would work for everything but is hard to use in all cases, or a simpler API which works for 99.999% of software requirements, but doesn't handle historical corner cases. Some APIs (such as Joda Time) model the cutover in a way which is reasonably simple, but ends up with some APIs behaving oddly.

For Noda Time I decided not to try to model this at all - if you're in a situation where you care about dates before the 19th century, you're likely to be in such a specialist situation that you're going to be implementing a lot of your own stuff anyway.

people

See more on this question at Stackoverflow