[Mono-dev] DateTime.Now incompatibility

Alan alan.mcgovern at gmail.com
Thu Aug 4 18:44:11 UTC 2016


Do you need `DateTime.UtcNow` instead of `DateTime.Now` ?

On 4 August 2016 at 19:07, Neale Ferguson <neale at sinenomine.net> wrote:

> If I run the following program:
>
> using System;
>
> public class Example
> {
>         public static void Main()
>         {
>                 Console.WriteLine(DateTime.Now);
>         }
> }
>
> Using the Great Britain timezone UTC and if I set the system date and
> time to a couple of hours before the transition (midnight on the 30th UTC)
> from daylight saving time back to standard time (2016-10-30 02:00:00):
>
> [neale at lneale3 - mono] sudo date --utc 103000002016.00
> Sun Oct 30 00:00:00 UTC 2016
>
> And run the program. I would expect that my time  would be UTC (1am) -
> which it is when I run it on Windows .NET. However, it comes out as
> midnight as it determines that we are in the ambiguous hour and simply
> applies the base offset.
>
>
> I am trying to determine what the logic should be for it to disambiguate
> this time and apply the correct offset and give me the same value as
> Windows.
>
> I did look at just plugging in the Reference Source version of the class
> but there is a lot of platform specific code in the Mono version so it is
> not a simple task.
>
> Neale
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.dot.net
> http://lists.dot.net/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20160804/c61ae2a6/attachment.html>


More information about the Mono-devel-list mailing list