Example #1
0
        public static TdrError.ErrorType tdrDateTime2Str(ref TdrVisualBuf buf, UInt64 datetime)
        {
            TdrError.ErrorType ret         = TdrError.ErrorType.TDR_NO_ERROR;
            TdrDateTime        tdrDateTime = new TdrDateTime();

            ret = tdrDateTime.parse(datetime);
            if (TdrError.ErrorType.TDR_NO_ERROR == ret)
            {
                ret = buf.sprintf("{0:d4}-{1:d2}-{2:d2} {3:d2}:{4:d2}:{5:d2}",
                                  tdrDateTime.tdrDate.nYear, tdrDateTime.tdrDate.bMon, tdrDateTime.tdrDate.bDay,
                                  tdrDateTime.tdrTime.nHour, tdrDateTime.tdrTime.bMin, tdrDateTime.tdrTime.bSec);
            }
            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
                ret = TdrError.ErrorType.TDR_ERR_INVALID_TDRDATETIME_VALUE;
            }

            return(ret);
        }
Example #2
0
        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);
        }
Example #3
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);
        }
Example #4
0
        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);
        }
Example #5
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);
        }
Example #6
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);
        }