Fix a bug that slipped in
This commit is contained in:
parent
f3a0000c2a
commit
5294854e1c
2 changed files with 18 additions and 12 deletions
|
|
@ -56,9 +56,12 @@ def is_task_due_today(task_def, check_date=None):
|
|||
|
||||
rec = task_def.get("recurrence", {})
|
||||
rec_type = rec.get("type")
|
||||
print(f"Analyzing {rec}")
|
||||
# print(f"Analyzing {rec}")
|
||||
|
||||
if rec_type =="weekly":
|
||||
if not rec_type:
|
||||
return False
|
||||
|
||||
elif rec_type =="weekly":
|
||||
day_name = check_date.strftime("%A")
|
||||
return day_name in rec.get("days", [])
|
||||
|
||||
|
|
@ -81,12 +84,13 @@ def is_task_due_today(task_def, check_date=None):
|
|||
elif rec_type == "interval":
|
||||
interval = rec.get("interval", 2)
|
||||
start_str = rec.get("start")
|
||||
anchor = (
|
||||
datetime.date.fromisoformat(start_str)
|
||||
if start_str
|
||||
else datetime.date(2000, 1, 1) # fixed default epoch
|
||||
)
|
||||
delta = (check_date - anchor).days
|
||||
# anchor = (
|
||||
# datetime.date.fromisoformat(start_str)
|
||||
# if start_str
|
||||
# else datetime.date(2000, 1, 1) # fixed default epoch
|
||||
# )
|
||||
# delta = (check_date - anchor).days
|
||||
delta = (check_date - start_str).days
|
||||
return delta >= 0 and delta % interval == 0
|
||||
|
||||
elif rec_type.startswith("flex"):
|
||||
|
|
@ -102,7 +106,6 @@ def get_existing_tasks():
|
|||
"""Fetch current tasks from Habitica."""
|
||||
url = f"{BASE_URL}/tasks/user"
|
||||
try:
|
||||
print(f"headers: {HEADERS}")
|
||||
response = requests.get(url, headers=HEADERS)
|
||||
response.raise_for_status()
|
||||
res_json = response.json()
|
||||
|
|
@ -177,4 +180,7 @@ def sync_tasks():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sync_tasks()
|
||||
if not USER_ID and not API_TOKEN:
|
||||
print("Need to set the USER_ID and API_TOKEN variables.")
|
||||
else:
|
||||
sync_tasks()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
---
|
||||
tasks:
|
||||
- text: "Treat Yo'self"
|
||||
notes: >-
|
||||
notes: |-
|
||||
Can we make cool lists?
|
||||
• Amazeballs
|
||||
• Deez nuts
|
||||
|
|
@ -139,7 +139,7 @@ tasks:
|
|||
day: first Saturday of November
|
||||
|
||||
- text: Order Sleep Part Replacements
|
||||
note: >-
|
||||
notes: |-
|
||||
Years worth of:
|
||||
- 12 nose pads
|
||||
- 6 short tubes
|
||||
|
|
|
|||
Loading…
Reference in a new issue