Search code examples
c#.netdatetimecalendarglobalization

DateTime.AddDays vs Calendar.AddDays


What is the difference between DateTime.AddDays and Calendar.AddDays?
Is DateTime type calendar independent?


Solution

  • DateTime.AddDays just converts days to ticks and adds this number of ticks to the date time. The default implementation of Calendar.AddDays does exactly the same. However, since it is a virtual method it can be implemented in specific calendar in a more complicated way, e.g. something like here: http://codeblog.jonskeet.uk/2010/12/01/the-joys-of-date-time-arithmetic/