public static NpgsqlDateTime Parse(string str) { if (str == null) { throw new NullReferenceException(); } switch (str = str.Trim().ToLowerInvariant()) { case "infinity": return(Infinity); case "-infinity": return(NegativeInfinity); default: try { int idxSpace = str.IndexOf(' '); string datePart = str.Substring(0, idxSpace); if (str.Contains("bc")) { datePart += " BC"; } int idxSecond = str.IndexOf(' ', idxSpace + 1); if (idxSecond == -1) { idxSecond = str.Length; } string timePart = str.Substring(idxSpace + 1, idxSecond - idxSpace - 1); return(new NpgsqlDateTime(NpgsqlDate.Parse(datePart), TimeSpan.Parse(timePart))); } catch (OverflowException) { throw; } catch { throw new FormatException(); } } }
internal static object ToDate(NpgsqlBackendTypeInfo typeInfo, byte[] bBackendData, Int16 typeSize, Int32 typeModifier) { string backendData = BackendEncoding.UTF8Encoding.GetString(bBackendData); return(NpgsqlDate.Parse(backendData)); }
public NpgsqlDateTime(NpgsqlDate date) : this(date, TimeSpan.Zero) { }
public NpgsqlDateTime(NpgsqlDate date, TimeSpan time, DateTimeKind kind = DateTimeKind.Unspecified) : this(KindToInternalType(kind), date, time) { }
NpgsqlDateTime(InternalType type, NpgsqlDate date, TimeSpan time) { _type = type; _date = date; _time = time; }
internal static object ToDate(NpgsqlBackendTypeInfo typeInfo, String backendData, Int16 typeSize, Int32 typeModifier) { return(NpgsqlDate.Parse(backendData)); }