⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 currenttime.cs

📁 微软的.NET论坛的源代码(COOL!!!)
💻 CS
字号:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetForums.Components;

namespace AspNetForums.Controls {

    // *********************************************************************
    //  StyleSkin
    //
    /// <summary>
    /// Encapsulated rendering of style based on the selected skin.
    /// </summary>
    // ********************************************************************/ 
    public class CurrentTime : Control {

        public CurrentTime() {
            Label label;

            // Add display text
            label = new Label();
            label.CssClass = "normalTextSmallBold";
            label.Text = "Current time: ";
            Controls.Add(label);

            // Add formatted time
            label = new Label();
            label.CssClass = "normalTextSmall";
            if (HttpContext.Current.Request.IsAuthenticated) {

                // Get the current user
                User user = Users.GetLoggedOnUser();

                // Adjust the current time
                label.Text = DateTime.Now.AddHours(user.Timezone - Globals.DBTimezone).ToString("MMM d, h:mm tt");

            } else {

                label.Text = DateTime.Now.ToString("MMM d, h:mm tt");
            }

            Controls.Add(label);

        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -