public TimeModule(ITimeNow timeNow) { _myTimeNow = timeNow; LocalZone = TimeZone.CurrentTimeZone; CurrentDate = DateTime.Now; CurrentYear = CurrentDate.Year; Daylight = LocalZone.GetDaylightChanges(CurrentYear); DaylightStart = Daylight.Start; DaylightEnd = Daylight.End; DaylightDelta = Daylight.Delta; UnixEpoch = DateTime.UnixEpoch; this.CurrentTimeUtc(); }
public void ShowDaylightSavingPeriod() { const string dataFmt = "{0,-30}{1}"; const string timeFmt = "{0,-30}{1:yyyy-MM-dd HH:mm}"; // Display the current date and time and show if they occur // in daylight saving time. Console.WriteLine("\n" + timeFmt, "Current date and time:", CurrentDate); Console.WriteLine(dataFmt, "Daylight saving time?", LocalZone.IsDaylightSavingTime(CurrentDate)); // Display the daylight saving time range for the current year. Console.WriteLine( "\nDaylight saving time for year {0}:", CurrentYear); Console.WriteLine("{0:yyyy-MM-dd HH:mm} to " + "{1:yyyy-MM-dd HH:mm}, delta: {2}", DaylightStart, DaylightEnd, DaylightDelta); }
private void AddDnsZone(IConfigurationSection dnsZone) { string zone = string.Empty; List <IPEndPoint> ips = new List <IPEndPoint>(); try { if (string.IsNullOrEmpty(dnsZone["zone"])) { throw new Exception("'zone' cannot be empty for DNS zone"); } zone = dnsZone["zone"]; var servers = dnsZone.GetSection("servers"); if (servers.GetChildren().Count() == 0 && servers.Value == null) { throw new Exception("'servers' cannot be empty for DNS zone"); } if (ConfigSectionArray(servers)) { foreach (var server in servers.GetChildren()) { ips.Add(Cleaners.MakeDnsIPEndPoint(server.Value)); } } else { ips.Add(Cleaners.MakeDnsIPEndPoint(servers.Value)); } var newLocalZone = new LocalZone(zone, ips); LocalZones.Add(newLocalZone); Logger.Debug($"'{newLocalZone}' has been added to DNS Zone Overrides"); } catch (Exception ex) { Logger.Error($"Could not add Local DNS Server", ex); } }