Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Jul 14, 2024
1 parent 5fd8ac6 commit 25c239f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/pybliotecario/components/arxiv_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@

logger = logging.getLogger(__name__)


def _is_last_cutoff(time_to_test, base_hour=18):
"""
Checks whether the given time to test corresponds to today
corresponds to the last cutoff.
Note that this will fail when there are holidays in the middle"""
# First we need to find out which day is today
today = datetime.now(timezone.utc)
# Now go back 48 hours
today -= timedelta(days=2)

last_cutoff = today.replace(hour=base_hour, minute=0, second=0, microsecond=0)
if last_cutoff > today:
last_cutoff -= timedelta(days=1)
cutoff_time = today.replace(hour=base_hour, minute=0, second=0, microsecond=0)
if cutoff_time > today:
cutoff_time -= timedelta(days=1)

# Now go back by two days (e.g., if we are looking at Wednesday, the papers were sent on Monday)
# but we need to wrap around the weekend

if last_cutoff.weekday() > 4: # Saturday or Sunday have no cutoff
last_cutoff -= timedelta(days=2)
wday = (min(today.weekday(), 4) - 2) % 5
last_cutoff = today.replace(day=wday)

return time_to_test >= last_cutoff

Expand Down

0 comments on commit 25c239f

Please sign in to comment.