Germany introduced a summer time shift on 6. April 1980.
Therefore I would expect the time shift on 1979 to GMT+1 and on 1980 to GMT+2
In Javascript this is correct:
new Date("1979-06-18T00:00:00.000")
new Date("1980-06-18T00:00:00.000")
How ever, when trying the same thing with C#, I have always 2 hours time shift.
var foo1 = new DateTime(1980, 6, 18, 0, 0, 0, DateTimeKind.Local).ToString("O");
var foo2 = new DateTime(1979, 6, 18, 0, 0, 0, DateTimeKind.Local).ToString("O");
I think this is the reason for a bug I am currently observing, when dealing with serialization and javascript, but I currently do not know, how to workaround it.
Basicaly I want to display a Birthdate via Json. I think because of the above reasons, everybuddy born before 6. April 1980, is born 1 hour erlier, which will be formatted as a day.
foo2
is serialized as /Date(298504800000)/
, which is 1 hour to early, while foo2 is exactly as expected:
My current Setup is:
- SQL Server with Birthday as
Date
column - EF 6 which materializes it as DateTimeKind.Unspecified (Therefore Local assumed)
- MVC5 JsonResult which gives it as shown as above
- Clientside format via KendoUI
{0:dd.MM.yyyy}
Is my assumption correct, this is a bug in the NET Framework? Do you have any Idea how to fix it?