Пример #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);
        }
Пример #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);
        }
Пример #3
0
        public static TdrError.ErrorType str2TdrDateTime(out UInt64 datetime, string strDateTime)
        {
            TdrError.ErrorType ret = TdrError.ErrorType.TDR_NO_ERROR;
            DateTime           dt;
            TdrDateTime        tdrDateTime = new TdrDateTime();

            if (DateTime.TryParse(strDateTime, out dt))
            {
                tdrDateTime.tdrDate.nYear = (short)dt.Year;
                tdrDateTime.tdrDate.bMon  = (byte)dt.Month;
                tdrDateTime.tdrDate.bDay  = (byte)dt.Day;

                tdrDateTime.tdrTime.nHour = (short)dt.TimeOfDay.Hours;
                tdrDateTime.tdrTime.bMin  = (byte)dt.TimeOfDay.Minutes;
                tdrDateTime.tdrTime.bSec  = (byte)dt.TimeOfDay.Seconds;

                tdrDateTime.toDateTime(out datetime);
            }
            else
            {
#if (DEBUG)
                StackTrace st = new StackTrace(true);
                for (int i = 0; i < st.FrameCount; i++)
                {
                    if (null != st.GetFrame(i).GetFileName())
                    {
                        Console.WriteLine(st.GetFrame(i).ToString());
                    }
                }
#endif
                datetime = 0;
                ret      = TdrError.ErrorType.TDR_ERR_INVALID_TDRDATETIME_VALUE;
            }

            return(ret);
        }