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

Function CalcFirstDayOfYearSinceEpoch

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

Source from the content-addressed store, hash-verified

63namespace {
64
65inline int32_t CalcFirstDayOfYearSinceEpoch(int year) {
66 int m400 = year % 400;
67 int m100 = m400 % 100;
68 int m4 = m100 % 4;
69
70 return (year - EPOCH_YEAR) * 365
71 + ((year - EPOCH_YEAR / 4 * 4 + ((m4 != 0) ? 4 - m4 : 0)) / 4 - 1)
72 - ((year - EPOCH_YEAR / 100 * 100 + ((m100 != 0) ? 100 - m100 : 0)) / 100 - 1)
73 + ((year - EPOCH_YEAR / 400 * 400 + ((m400 != 0) ? 400 - m400 : 0)) / 400 - 1);
74}
75
76// Returns the Monday that belongs to the first ISO 8601 week of 'year'. That is:
77// - If Jan 1 falls on Monday, Tuesday, Wednesday or Thursday, then the week of Jan 1 is

Callers 2

ToYearMethod · 0.85
ToYearMonthDayMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected