17 using System.Collections.Generic;
29 private DateTime _utcDateTime;
31 private readonly Dictionary<string, LocalTimeKeeper> _localTimeKeepers;
38 get {
return _utcDateTime; }
48 public TimeKeeper(DateTime utcDateTime, params DateTimeZone[] timeZones)
49 : this(utcDateTime, timeZones ?? Enumerable.Empty<DateTimeZone>())
60 public TimeKeeper(DateTime utcDateTime, IEnumerable<DateTimeZone> timeZones)
62 _utcDateTime = utcDateTime;
63 _localTimeKeepers = timeZones.Distinct().Select(x =>
new LocalTimeKeeper(utcDateTime, x)).ToDictionary(x => x.TimeZone.Id);
72 _utcDateTime = utcDateTime;
73 foreach (var timeZone
in _localTimeKeepers)
75 timeZone.Value.UpdateTime(utcDateTime);
98 if (!_localTimeKeepers.TryGetValue(timeZone.Id, out localTimeKeeper))
101 _localTimeKeepers[timeZone.Id] = localTimeKeeper;
103 return localTimeKeeper;
112 if (!_localTimeKeepers.ContainsKey(timeZone.Id))
114 _localTimeKeepers[timeZone.Id] =
new LocalTimeKeeper(_utcDateTime, timeZone);