1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using System; 9 10 namespace Antmicro.Renode.Utilities 11 { 12 // You might ask, why there is CustomDateTime calculating elapsed time in such a strange manner? 13 // This is because getting DateTime.Now on mono is veeeeeeeeery slow and this is much faster 14 public static class CustomDateTime 15 { 16 public static DateTime Now { get { return DateTime.UtcNow.Add(timeDifference); } } 17 CustomDateTime()18 static CustomDateTime() 19 { 20 var ournow = DateTime.Now; 21 var utcnow = TimeZoneInfo.ConvertTimeToUtc(ournow); 22 23 timeDifference = ournow - utcnow; 24 } 25 26 private static readonly TimeSpan timeDifference; 27 } 28 } 29 30