| 518 | |
| 519 | |
| 520 | class _DayOffset: |
| 521 | __slots__ = ["d", "julian", "hour", "minute", "second"] |
| 522 | |
| 523 | def __init__(self, d, julian, hour=2, minute=0, second=0): |
| 524 | min_day = 0 + julian # convert bool to int |
| 525 | if not min_day <= d <= 365: |
| 526 | raise ValueError(f"d must be in [{min_day}, 365], not: {d}") |
| 527 | |
| 528 | self.d = d |
| 529 | self.julian = julian |
| 530 | self.hour = hour |
| 531 | self.minute = minute |
| 532 | self.second = second |
| 533 | |
| 534 | def year_to_epoch(self, year): |
| 535 | days_before_year = _post_epoch_days_before_year(year) |
| 536 | |
| 537 | d = self.d |
| 538 | if self.julian and d >= 59 and calendar.isleap(year): |
| 539 | d += 1 |
| 540 | |
| 541 | epoch = (days_before_year + d) * 86400 |
| 542 | epoch += self.hour * 3600 + self.minute * 60 + self.second |
| 543 | |
| 544 | return epoch |
| 545 | |
| 546 | |
| 547 | class _CalendarOffset: |
no outgoing calls
no test coverage detected
searching dependent graphs…