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

Function GetFirstIso8601MondayOfYear

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

Returns the Monday that belongs to the first ISO 8601 week of 'year'. That is: - If Jan 1 falls on Monday, Tuesday, Wednesday or Thursday, then the week of Jan 1 is the first ISO 8601 week of 'year'. Therefore the Monday of the first ISO 8601 week in 'year' is the first Monday before Jan 2. - If Jan 1 falls on Friday, Saturday or Sunday, then the week of Jan 1 is the last ISO 8601 week of the prev

Source from the content-addressed store, hash-verified

81// 8601 week of the previous year. Therefore the Monday of the first ISO 8601 week in
82// 'year' is the first Monday following Jan 1.
83inline cctz::civil_day GetFirstIso8601MondayOfYear(int year) {
84 cctz::civil_day jan1 = cctz::civil_day(year, 1, 1);
85 if (cctz::get_weekday(jan1) <= cctz::weekday::thursday) {
86 // Get the previous Monday if 'jan1' is not already a Monday.
87 return cctz::next_weekday(jan1, cctz::weekday::monday) - 7;
88 } else {
89 // Get the next Monday.
90 return cctz::next_weekday(jan1, cctz::weekday::monday);
91 }
92}
93
94// Returns Sunday that belongs to the last ISO 8601 week of 'year'. That is:
95// - If Dec 31 falls on Thursday, Friday, Saturday or Sunday, then the week of Dec 31

Callers 3

Iso8601WeekOfYearMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected