FirebirdZonedValueToDateTimeOffsetResolver

A class used to resolve the value of a Firebird TIMESTAMP WITH TIME ZONE or TIME WITH TIME ZONE column, as returned by the driver, into a DateTimeOffset.

This IResolver<object, DateTimeOffset?> implementation converts the value of a TIMESTAMP WITH TIME ZONE or a TIME WITH TIME ZONE column, as returned by the FirebirdSql.Data.FirebirdClient driver, into a DateTimeOffset that holds the local value and the UTC offset of the time zone. It is used by the FirebirdZonedDateTimeToDateTimeOffsetPropertyHandler, the FirebirdZonedDateTimeToNullableDateTimeOffsetPropertyHandler, the FirebirdZonedTimeToDateTimeOffsetPropertyHandler and the FirebirdZonedTimeToNullableDateTimeOffsetPropertyHandler.

Firebird transfers these values in UTC together with the time zone, which the driver exposes as an FbZonedDateTime and an FbZonedTime. The local value is derived from the UTC value and the offset of the time zone.

  • A null or DBNull value is resolved as null.
  • A DateTimeOffset is returned as is.
  • An FbZonedDateTime is resolved into the local date and time with the offset of its time zone.
  • An FbZonedTime is resolved into the local time of day with the offset of its time zone. As a TIME WITH TIME ZONE value has no date, the date part of the result is 1970-01-01.

The offset is taken from the value itself when the driver provides it. Otherwise, it is resolved from the time zone name: UTC, a +HH:MM/-HH:MM offset, an Etc/GMT zone, or any other zone that is known to the operating system (TimeZoneInfo). An InvalidOperationException is thrown when the offset cannot be determined, and an ArgumentException when the type of the value is not supported.

The counterparts of this class are the DateTimeOffsetToFirebirdZonedDateTimeResolver and the DateTimeOffsetToFirebirdZonedTimeResolver, which convert a DateTimeOffset into the value written into the column.

Usability

var resolver = new FirebirdZonedValueToDateTimeOffsetResolver();
var value = resolver.Resolve(reader.GetValue(0)); // 2026-09-21 10:30:00 +03:00