Last active
July 18, 2025 13:43
-
-
Save pH-7/0692455748f8dc0e1ab775cf0311f962 to your computer and use it in GitHub Desktop.
Check if file has been checked for more than 24h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
def oneDaySinceLastCheck(timestamp_file='.touch_one_day_since_last_check'): | |
""" | |
Check whether it has been more than 24h since the last check. | |
""" | |
try: | |
lastCheck = os.path.getmtime(timestamp_file) | |
except FileNotFoundError: | |
lastCheck = 0 | |
if time.time() > 24*60*60 + lastCheck: | |
# Update timestamp file | |
with open(timestamp_file, 'w') as f: | |
f.write(str(time.time())) | |
return True | |
return False # Default value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment