📄 currenttime.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommunityServer.Components;
namespace CommunityServer.Controls {
// *********************************************************************
// StyleSkin
//
/// <summary>
/// Encapsulated rendering of style based on the selected skin.
/// </summary>
// ********************************************************************/
public class CurrentTime : Literal {
public virtual String Format {
get {
Object state = ViewState["Format"];
if ( state != null ) {
return (String)state;
}
return CommunityServer.Components.ResourceManager.GetString("Utility_CurrentTime_format");
}
set {
ViewState["Format"] = value;
}
}
public virtual String DateFormat {
get {
Object state = ViewState["DateFormat"];
if ( state != null ) {
return (String)state;
}
return CommunityServer.Components.ResourceManager.GetString("Utility_CurrentTime_dateFormat");
}
set {
ViewState["DateFormat"] = value;
}
}
protected override void Render (HtmlTextWriter writer) {
if (!CSContext.Current.SiteSettings.EnableCurrentTime)
return;
DateTime time;
// Set the time to the user's time
//
if (HttpContext.Current.Request.IsAuthenticated) {
time = DateTime.Now.AddHours(CSContext.Current.User.Profile.Timezone - CSContext.Current.SiteSettings.TimezoneOffset);
writer.Write( Format, time.ToString(DateFormat), CSContext.Current.User.Profile.Timezone.ToString() );
} else {
time = DateTime.Now;
writer.Write( Format, time.ToString(DateFormat), CSContext.Current.SiteSettings.TimezoneOffset.ToString() );
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -