be/src/exprs/vectorized/time_functions.cpp
/*
  Calculate nr of day since year 0 in new date-system (from 1615).
  @param year	  Year (exact 4 digit year, no year conversions)
  @param month  Month
  @param day	  Day
  @note 0000-00-00 is a valid date, and will return 0
  @return Days since 0000-00-00
*/
Calculate nr of day since year 0 in new date-system (from 1615).
Calculate nr of day since year 0 in new date - system ( from 1615 ) .
long TimeFunctions::compute_daynr(uint year, uint month, uint day) {
    long delsum;
    int temp;
    int y = year;
    if (y == 0 && month == 0) {
        return 0;
    }
    delsum = static_cast<long>(TimeFunctions::NUMBER_OF_NON_LEAP_YEAR * y + 31 * (static_cast<int>(month) - 1) +
                               static_cast<int>(day));
    if (month <= 2) {
        y--;
    } else {
        delsum -= static_cast<long>(static_cast<int>(month) * 4 + 23) / 10;
    }
    temp = ((y / 100 + 1) * 3) / 4;
    DCHECK(delsum + static_cast<int>(y) / 4 - temp >= 0);
    return (delsum + static_cast<int>(y) / 4 - temp);
}
long TimeFunctions :: compute_daynr ( uint year , uint month , uint day ) { long delsum ; int temp ; int y = year ; if ( y == 0 && month == 0 ) { return 0 ; } delsum = static_cast < long > ( TimeFunctions :: NUMBER_OF_NON_LEAP_YEAR * y + 31 * ( static_cast < int > ( month ) - 1 ) + static_cast < int > ( day ) ) ; if ( month <= 2 ) { y -- ; } else { delsum -= static_cast < long > ( static_cast < int > ( month ) * 4 + 23 ) / 10 ; } temp = ( ( y / 100 + 1 ) * 3 ) / 4 ; DCHECK ( delsum + static_cast < int > ( y ) / 4 - temp >= 0 ) ; return ( delsum + static_cast < int > ( y ) / 4 - temp ) ; }
Calculate nr of day since year 0 in new date-system (from 1615).
Calculate nr of day since year 0 in new date - system ( from 1615 ) .