Add deadline and date calcs.

master
josiah 3 years ago
parent 32255c40c7
commit 00fe2fb442

@ -1,5 +1,8 @@
from nio import AsyncClient, MatrixRoom, RoomMessageText
import datetime
import calendar
from molly.chat_functions import react_to_event, send_text_to_room
from molly.config import Config
from molly.storage import Storage
@ -91,12 +94,13 @@ class Command:
async def _new_org_todo(self):
"""Given a plaintext string, return org-formatted todo line."""
due_today = get_orgmode_deadline_string()
formatted_string = " ".join(self.args)
new_string = f"* TODO {formatted_string} \n"
new_string = f"* TODO {formatted_string}"
await send_text_to_room(self.client, self.room.room_id, f"creating new todo with {new_string}")
print(dir(self.config))
with open(self.config.orgmode_refile_path, "a") as orgfile:
orgfile.write(new_string)
orgfile.write(f"{new_string}\n{due_today}\n")
# return new_string
async def _unknown_command(self):
@ -105,3 +109,14 @@ class Command:
self.room.room_id,
f"Unknown command '{self.command}'. Try the 'help' command for more information.",
)
def get_orgmode_deadline_string():
"""Return an orgmode formatted todo deadline string, for example:
DEADLINE: <2021-08-14 Sat>
"""
date = datetime.date.today().isoformat()
weekday = calendar.day_name[datetime.date.today().weekday()]
deadline_string = f"DEADLINE: <{date} {weekday[0:3]}>"
return deadline_string

Loading…
Cancel
Save