예제 #1
0
        public override Instant Read(NpgsqlReadBuffer buf, int len, FieldDescription?fieldDescription = null)
        {
            var value = buf.ReadInt64();

            if (_convertInfinityDateTime)
            {
                if (value == long.MaxValue)
                {
                    return(Instant.MaxValue);
                }
                if (value == long.MinValue)
                {
                    return(Instant.MinValue);
                }
            }
            return(TimestampHandler.Decode(value));
        }
예제 #2
0
 ZonedDateTime INpgsqlSimpleTypeHandler <ZonedDateTime> .Read(NpgsqlReadBuffer buf, int len, FieldDescription?fieldDescription)
 {
     try
     {
         var value = buf.ReadInt64();
         if (value == long.MaxValue || value == long.MinValue)
         {
             throw new NotSupportedException("Infinity values not supported for timestamp with time zone");
         }
         return(TimestampHandler.Decode(value).InZone(_dateTimeZoneProvider[buf.Connection.Timezone]));
     }
     catch (Exception e) when(
         string.Equals(buf.Connection.Timezone, "localtime", StringComparison.OrdinalIgnoreCase) &&
         (e is TimeZoneNotFoundException || e is DateTimeZoneNotFoundException))
     {
         throw new TimeZoneNotFoundException(
                   "The special PostgreSQL timezone 'localtime' is not supported when reading values of type 'timestamp with time zone'. " +
                   "Please specify a real timezone in 'postgresql.conf' on the server, or set the 'PGTZ' environment variable on the client.",
                   e);
     }
 }