| 63 | namespace { |
| 64 | |
| 65 | inline 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 |
no outgoing calls
no test coverage detected