fork download
  1. using System;
  2. using static System.Console;
  3.  
  4. public class Program {
  5. public static void Main() {
  6. var minhaData = DateTime.UtcNow;
  7. WriteLine($"Hora universal {minhaData.ToLocalTime()}");
  8. var fuso = TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time");
  9. var diferenca = new DateTimeOffset(minhaData, TimeSpan.Zero);
  10. WriteLine($"Hora local {diferenca.ToOffset(fuso.GetUtcOffset(diferenca))}");
  11. WriteLine($"Diferença {fuso.GetUtcOffset(diferenca)}");
  12. }
  13. }
  14.  
  15. //https://pt.stackoverflow.com/q/88366/101
Runtime error #stdin #stdout #stderr 0.04s 17444KB
stdin
Standard input is empty
stdout
Hora universal 10/10/2019 10:36:20 AM
stderr
Unhandled Exception:
System.TimeZoneNotFoundException: Couldn't read time zone file /usr/share/zoneinfo/E. South America Standard Time ---> System.IO.FileNotFoundException: Could not find file "/usr/share/zoneinfo/E. South America Standard Time"
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <6649516e5b3542319fb262b421af0adb>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <6649516e5b3542319fb262b421af0adb>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <6649516e5b3542319fb262b421af0adb>:0 
  at System.TimeZoneInfo.FindSystemTimeZoneByFileName (System.String id, System.String filepath) [0x00002] in <6649516e5b3542319fb262b421af0adb>:0 
   --- End of inner exception stack trace ---
  at System.TimeZoneInfo.FindSystemTimeZoneByFileName (System.String id, System.String filepath) [0x0001d] in <6649516e5b3542319fb262b421af0adb>:0 
  at System.TimeZoneInfo.FindSystemTimeZoneByIdCore (System.String id) [0x0000c] in <6649516e5b3542319fb262b421af0adb>:0 
  at System.TimeZoneInfo.FindSystemTimeZoneById (System.String id) [0x00068] in <6649516e5b3542319fb262b421af0adb>:0 
  at Program.Main () [0x00021] in <eb045f559d6f4b618f41946b8e581d16>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TimeZoneNotFoundException: Couldn't read time zone file /usr/share/zoneinfo/E. South America Standard Time ---> System.IO.FileNotFoundException: Could not find file "/usr/share/zoneinfo/E. South America Standard Time"
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <6649516e5b3542319fb262b421af0adb>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <6649516e5b3542319fb262b421af0adb>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <6649516e5b3542319fb262b421af0adb>:0 
  at System.TimeZoneInfo.FindSystemTimeZoneByFileName (System.String id, System.String filepath) [0x00002] in <6649516e5b3542319fb262b421af0adb>:0 
   --- End of inner exception stack trace ---
  at System.TimeZoneInfo.FindSystemTimeZoneByFileName (System.String id, System.String filepath) [0x0001d] in <6649516e5b3542319fb262b421af0adb>:0 
  at System.TimeZoneInfo.FindSystemTimeZoneByIdCore (System.String id) [0x0000c] in <6649516e5b3542319fb262b421af0adb>:0 
  at System.TimeZoneInfo.FindSystemTimeZoneById (System.String id) [0x00068] in <6649516e5b3542319fb262b421af0adb>:0 
  at Program.Main () [0x00021] in <eb045f559d6f4b618f41946b8e581d16>:0