No February 30, 1712 in the .NET Swedish calendar?

In this wonderful talk about how weirdness in real data affects computer data types , John Skeet says that February had 30 days in Sweden in 1712 in a strange attempt to control leap years while adapting to the Gregorian calendar ( more on this on Wikipedia ) . Out of sheer 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 expected to see a terrific February 30th, but it only gives a boring March 1st. Thinking twice about this, the .NET DateTime class probably does not support instances with month = 2 and day = 30 in general ... but in any case, I would like to know if Sweden's .NET calendar implements on February 30, 1712 The date? Or is it really so, but my test is incorrect?

+5
source share
1 answer

Basically, the .NET calendar code does not support transitions between the Gregorian calendar and the Julian calendar ... and even if that were the case, I would not expect it to support the oddities of the Swedish situation, do one of them. Keep in mind that even in β€œnormal” cases, switching occurred at different times in different cultures. There are many other oddities around historical calendars, too - see the Noda Time page for some examples. I especially love the British calendar doing strange things in 1735.

Cutting tools are very difficult to simulate, as you end up with gaps that make all kinds of code just explode. You will either end up with an incredibly bulky API that will work for everything, but it is difficult to use in all cases, or a simpler API that works on 99.999% of the software requirements, but does not handle historical corner cases. Some APIs (such as Joda Time ) model thinning in a way that is simple enough, but ends up with some APIs behaving strangely.

For Noda Time, I decided not to try to model it at all - if you are in a situation where you like dates until the 19th century, you will probably be in such a specialist situation that in any case you will introduce a lot of your own things.

+2
source

Source: https://habr.com/ru/post/1232023/


All Articles