using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace EMIS.ViewModel { public class TestOperateView { public Guid? OperateID { get; set; } public Guid? UserID { get; set; } public string UserName { get; set; } public DateTime? StartTime { get; set; } public string StartTimeStr { get { return StartTime == null ? "" : StartTime.Value.ToLongDateString() + " " + StartTime.Value.ToLongTimeString(); } } public DateTime? EndTime { get; set; } public string EndTimeStr { get { return EndTime == null ? "" : EndTime.Value.ToLongDateString() + " " + EndTime.Value.ToLongTimeString(); } } public string WorkTimeStr { get { string workTime = ""; if (StartTime != null && EndTime != null) { TimeSpan ts1 = new TimeSpan(StartTime.Value.Ticks); TimeSpan ts2 = new TimeSpan(EndTime.Value.Ticks); TimeSpan ts3 = ts1.Subtract(ts2).Duration(); //你想转的格式 workTime = ts3.ToString("c").Substring(0, 8); } return workTime; } } public Guid? CreateUserID { get; set; } public DateTime? CreateTime { get; set; } public Guid? ModifyUserID { get; set; } public DateTime? ModifyTime { get; set; } } }