presto-main/src/main/java/io/prestosql/type/TimestampOperators.java/TimestampOperators/castToDate
class TimestampOperators:    @ScalarFunction("date")
    @ScalarOperator(CAST)
    @SqlType(StandardTypes.DATE)
    public static long castToDate(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value)
    {
        ISOChronology chronology;
        if (session.isLegacyTimestamp()) {
            // round down the current timestamp to days
            chronology = getChronology(session.getTimeZoneKey());
            long date = chronology.dayOfYear().roundFloor(value);
            // date is currently midnight in timezone of the session
            // convert to UTC
            long millis = date + chronology.getZone().getOffset(date);
            return TimeUnit.MILLISECONDS.toDays(millis);
        }

        return TimeUnit.MILLISECONDS.toDays(value);
    }