Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }