APISonar


io.prestosql.spi.type.StandardTypes.TIME

> io > prestosql > spi > type > StandardTypes > TIME
io APIs prestosql APIs spi APIs type APIs StandardTypes APIs TIME APIs

Example 1
public static long minuteFromTime(ConnectorSession session, @SqlType(StandardTypes.TIME) long time)
    {
        if (session.isLegacyTimestamp()) {
            return getChronology(session.getTimeZoneKey()).minuteOfHour().get(time);
        }
        else {
            return MINUTE_OF_HOUR.get(time);
        }
    }
Example 2
public static long castToTime(ConnectorSession session, @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long value)
    {
        // This is exactly the same operation as for TIME WITH TIME ZONE -> TIMESTAMP, as the representations
        // of those types are aligned in range that is covered by TIME WITH TIME ZONE.
        return castToTimestamp(session, value);
    }
Example 3
public static long addFieldValueTime(ConnectorSession session, @SqlType("varchar(x)") Slice unit, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.TIME) long time)
    {
        if (session.isLegacyTimestamp()) {
            ISOChronology chronology = getChronology(session.getTimeZoneKey());
            return modulo24Hour(chronology, getTimeField(chronology, unit).add(time, toIntExact(value)));
        }

        return modulo24Hour(getTimeField(UTC_CHRONOLOGY, unit).add(time, toIntExact(value)));
    }
Example 4
public static long castToTimeWithTimeZone(ConnectorSession session, @SqlType(StandardTypes.TIME) long value)
    {
        if (session.isLegacyTimestamp()) {
            return packDateTimeWithZone(value, session.getTimeZoneKey());
        }

        ISOChronology localChronology = getChronology(session.getTimeZoneKey());
        // This cast does treat TIME as wall time in session 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(localChronology.getZone().convertLocalToUTC(value, false), session.getTimeZoneKey());
    }
Example 5
public static long diffTime(ConnectorSession session, @SqlType("varchar(x)") Slice unit, @SqlType(StandardTypes.TIME) long time1, @SqlType(StandardTypes.TIME) long time2)
    {
        if (session.isLegacyTimestamp()) {
            // Session zone could have policy change on/around 1970-01-01, so we cannot use UTC
            ISOChronology chronology = getChronology(session.getTimeZoneKey());
            return getTimeField(chronology, unit).getDifferenceAsLong(time2, time1);
        }

        return getTimeField(UTC_CHRONOLOGY, unit).getDifferenceAsLong(time2, time1);
    }
Example 6
public static long intervalDayToSecondPlusTime(ConnectorSession session, @SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long left, @SqlType(StandardTypes.TIME) long right)
    {
        return modulo24Hour(getChronology(session.getTimeZoneKey()), left + right);
    }
Example 7
public static long castToTime(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value)
    {
        if (session.isLegacyTimestamp()) {
            return modulo24Hour(getChronology(session.getTimeZoneKey()), value);
        }

        return modulo24Hour(value);
    }