From 1ad0116128744f634f75fb1a3da750e26fe0e75d Mon Sep 17 00:00:00 2001 From: PyryL Date: Sun, 11 Dec 2022 15:52:33 +0200 Subject: [PATCH] string representation --- fixedcal/__init__.py | 1 + fixedcal/core/date.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/fixedcal/__init__.py b/fixedcal/__init__.py index e69de29..4e7a8c5 100644 --- a/fixedcal/__init__.py +++ b/fixedcal/__init__.py @@ -0,0 +1 @@ +from fixedcal.core.date import FixedDate \ No newline at end of file diff --git a/fixedcal/core/date.py b/fixedcal/core/date.py index 4269261..2bc407b 100644 --- a/fixedcal/core/date.py +++ b/fixedcal/core/date.py @@ -150,3 +150,12 @@ class FixedDate: new_date = self.datetime - o return FixedDate(date=new_date) raise ValueError("Invalid subtractor type, expected FixedDate or timedelta") + + def __str__(self) -> str: + """String representation of fixed date. + For year day, month is 14 and date 1. + + Returns: + str: Date as YYYY-MM-DD + """ + return f"{self._year:04.0f}-{self.month:02.0f}-{self.day_of_month:02.0f}"