29 lines
843 B
C#
29 lines
843 B
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web;
|
||
|
||
namespace 報到系統
|
||
{
|
||
public class Utils
|
||
{
|
||
/// <summary>
|
||
/// 依格式選項格式化簽到/簽退時間字串
|
||
/// timeFormat: "datetime" => 年月日時分秒 (原始值),"time" => 只取 HH:mm
|
||
/// </summary>
|
||
public static string FormatTimeValue(string timeValue, string timeFormat)
|
||
{
|
||
if (string.IsNullOrEmpty(timeValue))
|
||
return "";
|
||
|
||
if (timeFormat == "time")
|
||
{
|
||
// 取 HH:mm,格式為 "yyyy-MM-dd HH:mm:ss" 時從第11碼取5碼
|
||
return timeValue.Length >= 16 ? timeValue.Substring(11, 5) : timeValue;
|
||
}
|
||
|
||
// datetime 模式回傳原始值
|
||
return timeValue;
|
||
}
|
||
}
|
||
} |