Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a function to detect and correct for leap years #49

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion asmara.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
# Standard Library
from datetime import datetime as DT
from datetime import timezone as TZ
from datetime import timedelta as timedelta
from json import dump, load
from multiprocessing import Process, active_children
from os import getcwd, path, remove, walk
Expand Down Expand Up @@ -33,6 +35,9 @@
from pydub.utils import make_chunks, mediainfo
from requests import get, exceptions

#couldnt find the aboslute import for the function used here
import calendar as Calendar
physprop marked this conversation as resolved.
Show resolved Hide resolved

# First-Party
from utilities import utilities, severity

Expand Down Expand Up @@ -322,6 +327,18 @@ def __decoder__(self):
decode.split("-")[-3], "%j%H%M"
)
timeStamp = decode.split("-")[-4].split("+")[1]
currDate = DT.now(TZ.utc)
currYear = currDate.today().year
leapDate = f"2/29/{currYear}"
if Calendar.isleap(currYear):
physprop marked this conversation as resolved.
Show resolved Hide resolved
if DT.now(TZ.utc).strftime('%Y-%m-%d') > DT.strptime(leapDate,"%m/%d/%Y").strftime('%Y-%m-%d'):
expiryOffset = 86400
elif DT.now(TZ.utc).strftime('%Y-%m-%d') == DT.strptime(leapDate,"%m/%d/%Y").strftime('%Y-%m-%d'):
midnight = (DT.now(TZ.utc) + timedelta(days=1)).replace(hour=0, minute=0, microsecond=0, second=0)
expiryOffset = 86400 - (DT.now(TZ.utc) - midnight).seconds
print(expiryOffset)
else:
expiryOffset = 0
startTime = mktime(
DT(
DT.utcnow().year,
Expand All @@ -335,7 +352,7 @@ def __decoder__(self):
(int(timeStamp[:2]) * 60) * 60
+ int(timeStamp[2:]) * 60
)
now = mktime(DT.utcnow().timetuple())
now = mktime(DT.utcnow().timetuple()) + expiryOffset
filt = self.__FilterManager__(
headerTranslation.org,
headerTranslation.evnt,
Expand Down
Loading