Fucking leap years2

main
Terence Eden 2024-02-29 09:17:00 +00:00
rodzic 2fd688da74
commit fd0c309f7f
1 zmienionych plików z 16 dodań i 12 usunięć

Wyświetl plik

@ -27,15 +27,19 @@ while (year_counter >= year_joined ) :
year_counter -= 1
# The end of today is the start of tomorrow
# This means yesterday can take into account leap-years
today_end = datetime(year_counter, month_now, day_now, 00, 00) + timedelta(days=1)
yesterday_end = today_end - timedelta(days=1)
# Bitwise shift the integer representation and convert to milliseconds
max_id = ( int( today_end.timestamp() ) << 16 ) * 1000
min_id = ( int( yesterday_end.timestamp() ) << 16 ) * 1000
# Call the API
statuses = mastodon.account_statuses(id = my_id, max_id=max_id, min_id=min_id, limit="40", exclude_reblogs=True)
# Fetch further statuses if there are any
all_statuses = statuses #mastodon.fetch_remaining(statuses)
# Print the date and URl
for status in all_statuses :
print( str(status["created_at"])[:16] + " " + BeautifulSoup(status["content"], features="html.parser").get_text() + " - " + status["uri"] + "\n")
try:
today_end = datetime(year_counter, month_now, day_now, 00, 00) + timedelta(days=1)
yesterday_end = today_end - timedelta(days=1)
# Bitwise shift the integer representation and convert to milliseconds
max_id = ( int( today_end.timestamp() ) << 16 ) * 1000
min_id = ( int( yesterday_end.timestamp() ) << 16 ) * 1000
# Call the API
statuses = mastodon.account_statuses(id = my_id, max_id=max_id, min_id=min_id, limit="40", exclude_reblogs=True)
# Fetch further statuses if there are any
all_statuses = statuses #mastodon.fetch_remaining(statuses)
# Print the date and URl
for status in all_statuses :
print( str(status["created_at"])[:16] + " " + BeautifulSoup(status["content"], features="html.parser").get_text() + " - " + status["uri"] + "\n")
except:
print( str(year_counter) + " is not a leap year.")