예제 #1
0
        private ClockInfo CreateClockInfo(string clockId, TimeZoneInfo timeZoneInfo, DateTime refDt, TimeZoneInfo refTimeZoneInfo)
        {
            var timeTools = new TimeTools();

            var clockInfo = new ClockInfo(clockId, timeZoneInfo?.Id, refDt, refTimeZoneInfo?.Id);
            if (timeZoneInfo == null)
            {
                return clockInfo;
            }
            clockInfo.TzName = timeZoneInfo.DisplayName;
            clockInfo.Now =  TimeZoneInfo.ConvertTime(DateTimeOffset.UtcNow, timeZoneInfo);
            clockInfo.NowString = timeTools.TimeString( clockInfo.Now);

            return clockInfo;
        }
예제 #2
0
        private void GetDefaultClocks()
        {
            var pjsConfig = new PjsConfig();
            var timeTools = new TimeTools();

            var defaultDT = DateTime.UtcNow;
            var defaultTime = pjsConfig.GetAppSetting(Const.DefaultTime);
            if (string.IsNullOrEmpty(defaultTime) )
            {
                defaultTime = Const.DefaultTimeValue;
            }

            defaultDT = timeTools.GetDT(defaultTime);

            ThisPc = CreateClockInfo("ThisPC", TimeZoneInfo.Local, defaultDT, TimeZoneInfo.Local);
            ThisPc.PropertyChanged += ProcessClockRefTimeChange;

            var tzi = GetTimeZoneInfoDefault(Const.Clock1, Const.AUS);
            Clock1 = CreateClockInfo(Const.Clock1,tzi, defaultDT, TimeZoneInfo.Local);
            Clock1.PropertyChanged += ProcessClockRefTimeChange;

            tzi = GetTimeZoneInfoDefault(Const.Clock2, Const.GMT);
            Clock2 = CreateClockInfo(Const.Clock2, tzi, defaultDT, TimeZoneInfo.Local);
            Clock2.PropertyChanged += ProcessClockRefTimeChange;

            tzi = GetTimeZoneInfoDefault(Const.Clock3, Const.EST);
            Clock3 = CreateClockInfo(Const.Clock3, tzi, defaultDT, TimeZoneInfo.Local);
            Clock3.PropertyChanged += ProcessClockRefTimeChange;

            tzi = GetTimeZoneInfoDefault(Const.Clock4, Const.MST);
            Clock4 = CreateClockInfo(Const.Clock4, tzi, defaultDT, TimeZoneInfo.Local);
            Clock4.PropertyChanged += ProcessClockRefTimeChange;

            tzi = GetTimeZoneInfoDefault(Const.Clock5, Const.PST);
            Clock5 = CreateClockInfo(Const.Clock5, tzi, defaultDT, TimeZoneInfo.Local);
            Clock5.PropertyChanged += ProcessClockRefTimeChange;

            tzi = GetTimeZoneInfoDefault(Const.Clock6, Const.INDIA);
            Clock6 = CreateClockInfo(Const.Clock6, tzi, defaultDT, TimeZoneInfo.Local);
            Clock6.PropertyChanged += ProcessClockRefTimeChange;

            tzi = GetTimeZoneInfoDefault(Const.Clock7, Const.CHINA);
            Clock7 = CreateClockInfo(Const.Clock6, tzi, defaultDT, TimeZoneInfo.Local);
            Clock7.PropertyChanged += ProcessClockRefTimeChange;

            tzi = GetTimeZoneInfoDefault(Const.Clock8, Const.AST);
            Clock8 = CreateClockInfo(Const.Clock8, tzi, defaultDT, TimeZoneInfo.Local);
            Clock8.PropertyChanged += ProcessClockRefTimeChange;

            tzi = GetTimeZoneInfoDefault(Const.Clock9, Const.EUR);
            Clock9 = CreateClockInfo(Const.Clock9, tzi, defaultDT, TimeZoneInfo.Local);
            Clock9.PropertyChanged += ProcessClockRefTimeChange;
        }
예제 #3
0
 public void UpdateClockTime(ClockInfo clockInfo)
 {
     if (clockInfo?.TimeZoneInfo == null)
     {
         return;
     }
     clockInfo.Now = TimeZoneInfo.ConvertTime(DateTimeOffset.UtcNow, clockInfo.TimeZoneInfo);
     var timeTools = new TimeTools();
     clockInfo.NowString = timeTools.TimeString(clockInfo.Now);
 }