zoukankan      html  css  js  c++  java
  • 设置系统时钟

     private DispatcherTimer _timer;
    
    
       private void SetTimeElaspInStatusBar()
            {
                try
                {
                    
                    _timer = new DispatcherTimer();
                    _timer.Tick += (sender, e) =>
                    {
                        DateTime dtNow = DateTime.Now;
                        TimeSpan interval = dtNow - _enterSystemTime;
    
                        this.barElapsedTime.Content = null;
    
                        #region
    
                        TimeZoneInfo currentTimeZone = TimeZoneUtil.GetLocalTimeZone();
                        if (currentTimeZone != null)
                        {
                            string str = currentTimeZone.Id;
    
                            this.barElapsedTime.Content += "     Local Time(" + str + " )"
                                + ": "
                                + dtNow.ToString("MM/dd/yyyy HH:mm:ss");
    
                            //DateTimeUtil.ConvertToUniversalTimeString(this._enterSystemTime, "MM/dd/yyyy HH:mm:ss");
                        }
    
                        //this.barElapsedTime.Content += "     UTC Time : "
                        //    + DateTimeUtil.ConvertToUniversalTimeString(dtNow, "MM/dd/yyyy HH:mm:ss");
    
                        DateTime? dtUTC =TimeZoneUtil.ConvertTimeToUTC(dtNow);
                     
                        if (dtUTC != null)
                        {
                            this.barElapsedTime.Content += "     UTC Time : "
                                +((DateTime)dtUTC).ToString("MM/dd/yyyy HH:mm:ss");
                        }
    
    
                        ////Convert To "Central America Standard Time"
                        //DateTime? dtUSCenter = TimeZoneUtil.ConvertFromUTC((DateTime)dtUTC, "Central America Standard Time");
    
                        //if (dtUSCenter != null)
                        //{
    
                        //    this.barElapsedTime.Content += "     UTC Time to  Central America Standard Time: "
                        //                               + ((DateTime)dtUSCenter).ToString("MM/dd/yyyy HH:mm:ss");
                        //}
    
                        #endregion
    
                        this.barElapsedTime.Content += "        Elapsed Time: " + (interval.Days > 0 ? interval.Days + " day(s) " : "") +
                           new DateTime(1900, 1, 1, interval.Hours, interval.Minutes, interval.Seconds).ToString("HH:mm:ss");
    
                        //
                        if (EventBinder.SystemTimeOutCheck.IsCheckTimeOut)
                        {
                            EventBinder.SystemTimeOutCheck.Check();
                        }
                       // SystemThreadStarter.StartGetUrlThread();
                    };
                    _timer.Interval = TimeSpan.FromSeconds(1);
                    _timer.Start();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
  • 相关阅读:
    Xamarin studio配置问题
    安装moogodb
    什么是作用域, 什么是闭包, 什么是原型链,什么是递归, 什么是函数函数声明,什么是函数表达式,继承,this 指向
    前端框架Vue、angular、React的优点和缺
    判断终端是IOS 或 是Android
    VS code终端错位
    安装Flutter
    web直传OSS设置 头部信息【坑】
    从零创建react项目
    webpack报错vue-template-compiler 版本不对
  • 原文地址:https://www.cnblogs.com/quietwalk/p/3531644.html
Copyright © 2011-2022 走看看