public static DATE Parse(string s) { DATE date = null; if (!TryParse(s, out date)) { throw new FormatException("Cannot parse DATE object!"); } return(date); }
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); }
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); }
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); }
internal static byte[] GetBytes(DATE dt) => BitConverter.GetBytes(dt.Ticks);