示例#1
0
        public static DATE Parse(string s)
        {
            DATE date = null;

            if (!TryParse(s, out date))
            {
                throw new FormatException("Cannot parse DATE object!");
            }
            return(date);
        }
示例#2
0
        public static bool TryParse(string s, out DATE date)
        {
            uint ticks = 0;

            if (PlcOpenDateConverter.TryParseToTicks(s, out ticks))
            {
                date = new DATE(ticks);
                return(true);
            }
            date = null;
            return(false);
        }
示例#3
0
        public static bool TryParse(string str, out DATE date)
        {
            DateTime time;
            uint     ticks = 0;

            if (TryParseToTicks(str, out ticks))
            {
                date = new DATE(ticks);
                return(true);
            }
            if (TryParseDateTime(str, out time))
            {
                date = new DATE(time);
                return(true);
            }
            date = null;
            return(false);
        }
示例#4
0
 public static bool TryConvert(object source, out DATE timeOfDay)
 {
     timeOfDay = null;
     if (source.GetType() == typeof(long))
     {
         timeOfDay = Create((long)source);
     }
     else if (source.GetType() == typeof(uint))
     {
         timeOfDay = Create((uint)source);
     }
     else if (source.GetType() == typeof(DateTime))
     {
         timeOfDay = Create((DateTime)source);
     }
     else if (source.GetType() == typeof(string))
     {
         TryParse((string)source, out timeOfDay);
     }
     return(timeOfDay != null);
 }
示例#5
0
 internal static byte[] GetBytes(DATE dt) =>
 BitConverter.GetBytes(dt.Ticks);