Skip to content

Commit

Permalink
Use date instead of datetime where appplicable
Browse files Browse the repository at this point in the history
  • Loading branch information
BelKed committed Jul 14, 2024
1 parent 19fcf4a commit 2f60ea7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions edupage_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,23 @@ def send_message(

return Messages(self).send_message(recipients, body)

def get_timetable(self, date: datetime) -> Optional[Timetable]:
"""Get timetable.
def get_timetable(self, date: date) -> Optional[Timetable]:
"""Get timetable for the logged-in user on a specified date.
Args:
date (datetime): Date from which you want to get timetable.
date (datetime.date): The date for which you want to get timetable
Returns:
Optional[Timetable]: Timetable object for entered date.
Optional[Timetable]: `Timetable` object for the specified date, if available; otherwise, `None`.
"""

return Timetables(self).get_timetable(date)

def get_lunches(self, date: datetime) -> Optional[Lunch]:
def get_lunches(self, date: date) -> Optional[Lunch]:
"""Get lunches.
Args:
date (datetime): Date from which you want to get lunches.
date (datetime.date): Date from which you want to get lunches.
Returns:
Optional[Lunch]: Lunch object for entered date.
Expand Down Expand Up @@ -274,7 +274,7 @@ def get_school_year(self) -> int:
def get_foreign_timetable(
self,
target: Union[EduTeacher, EduStudent, Class, Classroom],
date: datetime,
date: date,
) -> Optional[list[LessonSkeleton]]:
"""Get timetable of a teacher, student, class, or classroom for a specific date.
Expand Down
8 changes: 4 additions & 4 deletions edupage_api/foreign_timetables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from dataclasses import dataclass
from datetime import datetime, time, timedelta
from datetime import date, datetime, time, timedelta
from typing import List, Optional, Union

from edupage_api.classes import Class, Classes
Expand Down Expand Up @@ -32,7 +32,7 @@ class LessonSkeleton:


class ForeignTimetables(Module):
def __get_this_week_weekday(self, date: datetime, n: int) -> datetime:
def __get_this_week_weekday(self, date: date, n: int) -> date:
return date - timedelta(days=(date.weekday() - n))

def get_school_year(self):
Expand All @@ -43,7 +43,7 @@ def get_school_year(self):

return dp.get("year")

def __get_timetable_data(self, id: int, table: str, date: datetime):
def __get_timetable_data(self, id: int, table: str, date: date):
this_monday = self.__get_this_week_weekday(date, 0)
this_sunday = self.__get_this_week_weekday(date, 6)

Expand Down Expand Up @@ -92,7 +92,7 @@ def __get_timetable_data(self, id: int, table: str, date: datetime):
def get_foreign_timetable(
self,
target: Union[EduTeacher, EduStudent, Class, Classroom],
date: datetime,
date: date,
) -> Optional[List[LessonSkeleton]]:

lookup = {
Expand Down
4 changes: 2 additions & 2 deletions edupage_api/lunches.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from dataclasses import dataclass
from datetime import datetime
from datetime import date, datetime
from typing import List, Optional

from edupage_api.exceptions import (
Expand Down Expand Up @@ -103,7 +103,7 @@ def sign_off(self, edupage: EdupageModule):

class Lunches(Module):
@ModuleHelper.logged_in
def get_lunch(self, date: datetime):
def get_lunch(self, date: date):
date_strftime = date.strftime("%Y%m%d")
request_url = (
f"https://{self.edupage.subdomain}.edupage.org/menu/?date={date_strftime}"
Expand Down
6 changes: 3 additions & 3 deletions edupage_api/timetables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from dataclasses import dataclass
from datetime import datetime, time
from datetime import date, datetime, time
from typing import List, Optional

from edupage_api.classes import Class, Classes
Expand Down Expand Up @@ -87,7 +87,7 @@ def get_last_lesson(self):


class Timetables(Module):
def __get_date_plan(self, date: datetime):
def __get_date_plan(self, date: date):
csrf_request_url = (
f"https://{self.edupage.subdomain}.edupage.org/dashboard/eb.php?mode=ttday"
)
Expand Down Expand Up @@ -133,7 +133,7 @@ def __get_date_plan(self, date: datetime):
return date_plans.get("plan")

@ModuleHelper.logged_in
def get_timetable(self, date: datetime) -> Optional[Timetable]:
def get_timetable(self, date: date) -> Optional[Timetable]:
plan = self.__get_date_plan(date)

lessons = []
Expand Down

0 comments on commit 2f60ea7

Please sign in to comment.