麦田

不积跬步无以至千里.

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
        private void buttonSure_Click(object sender, EventArgs e)
        {
           // MessageBox.Show(this.userControlChoiceTime1.GetUserChoiceTime().ToLocalTime().ToString());
            DateTime userChoiceTime = this.userControlChoiceTime1.GetUserChoiceTime();
            //TimeSpan ts1 = new TimeSpan(userChoiceTime.Ticks);
            //TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);
            //TimeSpan ts = ts1.Subtract(ts2).Duration();
            if (ConvertDateTimeInt(userChoiceTime) - ConvertDateTimeInt(DateTime.Now)<0)
            {
                MessageBox.Show("O(∩_∩)O貌似不能回到过去发邮件!");
            }
        }

        // DateTime时间格式转换为Unix时间戳格式              
        public int ConvertDateTimeInt(System.DateTime time)              
        {                  
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));                  
            return (int)(time - startTime).TotalSeconds;              
        } 

 

posted on 2012-12-15 09:56  一些记录  阅读(616)  评论(0)    收藏  举报