71 lines
2.0 KiB
C#
71 lines
2.0 KiB
C#
|
//**********************************************//
|
|||
|
//作者:何健#
|
|||
|
//日期:#2016.10.17#
|
|||
|
//简述:#模块可公有方法,帮助类#
|
|||
|
//*********************************************//
|
|||
|
|
|||
|
using System;
|
|||
|
using Thousandto.Core.Base;
|
|||
|
|
|||
|
namespace Thousandto.Code.Logic
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 类ToolsHelp说明
|
|||
|
/// </summary>
|
|||
|
public class HelpTools
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 根据时间戳获取具体时间
|
|||
|
/// </summary>
|
|||
|
/// <param name="stamp"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static string GetTimeWithTimestamp(long stamp)
|
|||
|
{
|
|||
|
string ret = null;
|
|||
|
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
|||
|
TimeSpan toNow = new TimeSpan(stamp * 10000000);
|
|||
|
dtStart = dtStart.Add(toNow);
|
|||
|
ret = dtStart.ToString(LanguageSystem.GetTimeFormatString() + " HH:mm:ss");
|
|||
|
return ret;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据时间戳获取时间的小时:分钟:秒
|
|||
|
/// </summary>
|
|||
|
/// <param name="stamp"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static string GetHourTimeWithTimestamp(long stamp)
|
|||
|
{
|
|||
|
long hour;
|
|||
|
long minute;
|
|||
|
long sec;
|
|||
|
string ret;
|
|||
|
if (stamp > 0)
|
|||
|
{
|
|||
|
minute = stamp / 60;
|
|||
|
hour = minute / 60;
|
|||
|
minute = minute % 60;
|
|||
|
sec = stamp % 60;
|
|||
|
ret = string.Format("{0}:{1}:{2}", hour, minute, sec);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ret = "00:00";
|
|||
|
}
|
|||
|
|
|||
|
return ret;
|
|||
|
}
|
|||
|
|
|||
|
//获取颜色BBCode
|
|||
|
public static string GetColorBBCodeWithRGB(string rgb, string sText)
|
|||
|
{
|
|||
|
string ret = string.Empty;
|
|||
|
if (rgb != string.Empty && sText != string.Empty)
|
|||
|
{
|
|||
|
ret = string.Format("[{0}]{1}[-]", rgb, sText);
|
|||
|
}
|
|||
|
return ret;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|