presto-main/src/main/java/io/prestosql/type/TimestampWithTimeZoneOperators.java/TimestampWithTimeZoneOperators/castToTimeWithTimeZone
class TimestampWithTimeZoneOperators:    @ScalarOperator(CAST)
    @SqlType(StandardTypes.TIME_WITH_TIME_ZONE)
    public static long castToTimeWithTimeZone(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long value)
    {
        if (session.isLegacyTimestamp()) {
            int millis = modulo24Hour(unpackChronology(value), unpackMillisUtc(value));
            return packDateTimeWithZone(millis, unpackZoneKey(value));
        }

        long millis = modulo24Hour(castToTimestamp(session, value));
        ISOChronology localChronology = unpackChronology(value);
        // This cast does treat TIME as wall time in given TZ. This means that in order to get
        // its UTC representation we need to shift the value by the offset of TZ.
        // We use value offset in this place to be sure that we will have same hour represented
        // in TIME WITH TIME ZONE. Calculating real TZ offset will happen when really required.
        // This is done due to inadequate TIME WITH TIME ZONE representation.
        return packDateTimeWithZone(millis - localChronology.getZone().getOffset(millis), unpackZoneKey(value));
    }