[Mono-dev] DateTime.ToBinary / TZ differences between windows and linux

David Schmitt david at dasz.at
Tue May 21 09:27:34 UTC 2013


I've used DateTime.ToBinary() to serialize dates between linux (mono) 
and windows (ms.net). All dates are in CEST (central european standard 
time), but the timezone's definitions differs between mono and ms.net, 
causing the "wrong" time to be displayed.

On a recent mono 3.x:

> csharp> new DateTime(1979,6,30).IsDaylightSavingTime()
> false
> csharp> new DateTime(1980,6,30).IsDaylightSavingTime()
> true
> csharp>

ms.net on the other hand returns true for both calls. This in turn leads 
to ToUniversal() to return different times.

mono's implementation is arguably more correct with regards to reality, 
as 1979-06-30 really did *not* have DST and 1980-06-30 really *did* have 

Of course, the best way to work around this would be to convert the 
complete application and database to use UTC, except when displaying to 
the user. This is already on the roadmap for other reasons. ;-)

The questions for mono-devel are rather:

   * Is this behavior intentional?
   * Is there a quick workaround to match mono's and ms.net's behavior?

Regards, David

More information about the Mono-devel-list mailing list