示例#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
        public override void Write(Instant value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
        {
            if (_convertInfinityDateTime)
            {
                if (value == Instant.MaxValue)
                {
                    buf.WriteInt64(long.MaxValue);
                    return;
                }

                if (value == Instant.MinValue)
                {
                    buf.WriteInt64(long.MinValue);
                    return;
                }
            }
            TimestampHandler.WriteInteger(value, buf);
        }
示例#3
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);
     }
 }
 void INpgsqlSimpleTypeHandler <LocalDateTime> .Write(LocalDateTime value, NpgsqlWriteBuffer buf, NpgsqlParameter?parameter)
 => TimestampHandler.WriteLocalDateTime(value, buf);
 LocalDateTime INpgsqlSimpleTypeHandler <LocalDateTime> .Read(NpgsqlReadBuffer buf, int len, FieldDescription?fieldDescription)
 => TimestampHandler.ReadLocalDateTime(buf);