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

Method Iso8601WeekNumberingYear

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

Source from the content-addressed store, hash-verified

290}
291
292int DateValue::Iso8601WeekNumberingYear() const {
293 if (UNLIKELY(!IsValid())) return -1;
294 const cctz::civil_day today = EPOCH_DATE + days_since_epoch_;
295 const cctz::civil_day first_monday = GetFirstIso8601MondayOfYear(today.year());
296 const cctz::civil_day last_sunday = GetLastIso8601SundayOfYear(today.year());
297
298 // 0001-01-01 is Monday in the proleptic Gregorian calendar.
299 // 0001-01-01 belongs to year 0001.
300 // 9999-12-31 is Friday in the proleptic Gregorian calendar.
301 // 9999-12-31 belongs to year 9999.
302 if (today >= first_monday && today <= last_sunday) {
303 return today.year();
304 } else if (today > last_sunday) {
305 DCHECK(today.year() >= MIN_YEAR && today.year() < MAX_YEAR);
306 return today.year() + 1;
307 } else {
308 DCHECK(today < first_monday);
309 DCHECK(today.year() > MIN_YEAR && today.year() <= MAX_YEAR);
310 return today.year() - 1;
311 }
312}
313
314DateValue DateValue::AddDays(int64_t days) const {
315 if (UNLIKELY(!IsValid()

Callers 4

TESTFunction · 0.80
FormatMethod · 0.80

Calls 3

yearMethod · 0.80

Tested by 1

TESTFunction · 0.64