Created
September 22, 2015 10:17
-
-
Save alpinskiy/50e873058204ea0fbbdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace UtcOffsetQuirks | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
// Комментарии ниже - вывод программы, запущенной на | |
// компьютере с русской локалью 22 сентября 2014 года. | |
PrintWithUtcOffset(new DateTime( | |
year: 2014, | |
month: 10, | |
day: 26, | |
hour: 0, | |
minute: 59, | |
second: 59, | |
kind: DateTimeKind.Local)); | |
// 26.10.2014 0:59:59 | |
// 04:00:00 | |
PrintWithUtcOffset(new DateTime( | |
year: 2014, | |
month: 10, | |
day: 26, | |
hour: 1, | |
minute: 0, | |
second: 0, | |
kind: DateTimeKind.Local)); | |
// 26.10.2014 1:00:00 | |
// 03:00:00 | |
} | |
public static void PrintWithUtcOffset(DateTime dateTime) | |
{ | |
Console.WriteLine(dateTime); | |
Console.WriteLine(UtcOffset(dateTime)); | |
Console.WriteLine(); | |
} | |
public static TimeSpan UtcOffset(DateTime dateTime) | |
{ | |
return dateTime - dateTime.ToUniversalTime(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment