| 290 | } |
| 291 | |
| 292 | int 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 | |
| 314 | DateValue DateValue::AddDays(int64_t days) const { |
| 315 | if (UNLIKELY(!IsValid() |