public static TdrError.ErrorType tdrDateTime2Str(ref TdrVisualBuf buf, ulong datetime) { TdrDateTime time = new TdrDateTime(); if (time.parse(datetime) == TdrError.ErrorType.TDR_NO_ERROR) { object[] args = new object[] { time.tdrDate.nYear, time.tdrDate.bMon, time.tdrDate.bDay, time.tdrTime.nHour, time.tdrTime.bMin, time.tdrTime.bSec }; return(buf.sprintf("{0:d4}-{1:d2}-{2:d2} {3:d2}:{4:d2}:{5:d2}", args)); } return(TdrError.ErrorType.TDR_ERR_INVALID_TDRDATETIME_VALUE); }
public static TdrError.ErrorType str2TdrDateTime(out ulong datetime, string strDateTime) { DateTime time; TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; TdrDateTime time2 = new TdrDateTime(); if (DateTime.TryParse(strDateTime, out time)) { time2.tdrDate.nYear = (short)time.Year; time2.tdrDate.bMon = (byte)time.Month; time2.tdrDate.bDay = (byte)time.Day; time2.tdrTime.nHour = (short)time.TimeOfDay.Hours; time2.tdrTime.bMin = (byte)time.TimeOfDay.Minutes; time2.tdrTime.bSec = (byte)time.TimeOfDay.Seconds; time2.toDateTime(out datetime); return(type); } datetime = 0L; return(TdrError.ErrorType.TDR_ERR_INVALID_TDRDATETIME_VALUE); }
public static TdrError.ErrorType tdrDateTime2Str(ref TdrVisualBuf buf, ulong datetime) { TdrDateTime tdrDateTime = new TdrDateTime(); TdrError.ErrorType result; if (tdrDateTime.parse(datetime) == TdrError.ErrorType.TDR_NO_ERROR) { result = buf.sprintf("{0:d4}-{1:d2}-{2:d2} {3:d2}:{4:d2}:{5:d2}", new object[] { tdrDateTime.tdrDate.nYear, tdrDateTime.tdrDate.bMon, tdrDateTime.tdrDate.bDay, tdrDateTime.tdrTime.nHour, tdrDateTime.tdrTime.bMin, tdrDateTime.tdrTime.bSec }); } else { result = TdrError.ErrorType.TDR_ERR_INVALID_TDRDATETIME_VALUE; } return(result); }
public static TdrError.ErrorType str2TdrDateTime(out ulong datetime, string strDateTime) { TdrError.ErrorType result = TdrError.ErrorType.TDR_NO_ERROR; TdrDateTime tdrDateTime = new TdrDateTime(); DateTime dateTime; if (DateTime.TryParse(strDateTime, ref dateTime)) { tdrDateTime.tdrDate.nYear = (short)dateTime.get_Year(); tdrDateTime.tdrDate.bMon = (byte)dateTime.get_Month(); tdrDateTime.tdrDate.bDay = (byte)dateTime.get_Day(); tdrDateTime.tdrTime.nHour = (short)dateTime.get_TimeOfDay().get_Hours(); tdrDateTime.tdrTime.bMin = (byte)dateTime.get_TimeOfDay().get_Minutes(); tdrDateTime.tdrTime.bSec = (byte)dateTime.get_TimeOfDay().get_Seconds(); tdrDateTime.toDateTime(out datetime); } else { datetime = 0uL; result = TdrError.ErrorType.TDR_ERR_INVALID_TDRDATETIME_VALUE; } return(result); }