MCPcopy Create free account
hub / github.com/apache/impala / ToYearMonthDay

Method ToYearMonthDay

be/src/runtime/date-value.cc:223–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223bool DateValue::ToYearMonthDay(int* year, int* month, int* day) const {
224 DCHECK(year != nullptr);
225 DCHECK(month != nullptr);
226 DCHECK(day != nullptr);
227 if (UNLIKELY(!IsValid())) return false;
228
229 // Uses the same method to calculate the year as DateValue::ToYear().
230 int tmp = days_since_epoch_ * 400 + 287811200;
231 int first_year = (tmp - 591) / 146097;
232 int last_year = (tmp + 288) / 146097;
233
234 int jan1_dse = CalcFirstDayOfYearSinceEpoch(last_year);
235 if (jan1_dse <= days_since_epoch_) {
236 *year = last_year;
237 } else {
238 *year = first_year;
239 jan1_dse -= IsLeapYear(first_year) ? 366 : 365;
240 }
241 DCHECK(*year >= MIN_YEAR && *year <= MAX_YEAR);
242
243 // Day of year. 0 is used for January 1.
244 int days_since_jan1 = days_since_epoch_ - jan1_dse;
245
246 return GetMonthAndDayFromDaysSinceJan1(*year, days_since_jan1, month, day);
247}
248
249int DateValue::WeekDay() const {
250 if (UNLIKELY(!IsValid())) return -1;

Callers 15

TEST_PFunction · 0.80
QuarterMethod · 0.80
MonthMethod · 0.80
DayOfMonthMethod · 0.80
LongMonthNameMethod · 0.80
MaskImplFunction · 0.80
DoTruncFunction · 0.80
DoExtractFunction · 0.80
ValidateDateFunction · 0.80
TESTFunction · 0.80
FormatDefaultMethod · 0.80
FormatMethod · 0.80

Calls 3

IsLeapYearFunction · 0.85

Tested by 5

TEST_PFunction · 0.64
ValidateDateFunction · 0.64
TESTFunction · 0.64
TestToYearMonthDayMethod · 0.64