implemented functions to get human readable dates

This commit is contained in:
Hellow
2024-02-14 23:37:43 +01:00
parent 420deb16cf
commit 6be934e374
5 changed files with 71 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ import os.path
from pathlib import Path
import requests
from ics import Calendar
from ics import Calendar, Event
from ..utils import config, error, prompt, ICS_FILE
from ..feeds import *
@@ -42,7 +42,7 @@ class Routine:
raise error.InvalidCredential(f"Invalid credentials for {feed.__name__}.")
@staticmethod
def get_ics(use_cached: bool = False) -> Path:
def get_ics(use_cached: bool = False) -> Calendar:
if use_cached and ICS_FILE.exists():
with ICS_FILE.open("r") as f:
return Calendar(f.read())
@@ -66,6 +66,10 @@ class Routine:
with ICS_FILE.open("r") as f:
return Calendar(f.read())
@staticmethod
def get_event_string(event: Event) -> str:
return f""
def run(self):

View File

@@ -1,7 +1,19 @@
from . import Routine
from ..feeds import Feed
from ..feeds import Feed, TwitterFeed
from ..utils import date
from ics import Calendar
class Development(Routine):
def run(self):
print(self.get_ics())
calendar = self.get_ics()
for event in calendar.events:
print(event.name, date.event_formatting_values(event, "de"))
break
event_description = f"""
Wir treffen uns {event.begin.humanize(locale="de")} zum {event.name}."""
print(event_description.strip())
print()