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
| 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. |
| 83 | inline 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 |
no outgoing calls
no test coverage detected