Month

SchnipSchnap
mail@pastecode.io avatar
unknown
python
2 years ago
919 B
3
Indexable
Never
class Month:
    def __init__(self):
        self.date_time_now = datetime.now()
        self.month = datetime.now().month
        self.year = datetime.now().year

    def getDaysFromMonthToList(self) -> list:
        d = 32
        while True:
            try:
                self.days = [
                    datetime.strftime(
                        datetime(year=self.year, month=self.month, day=x), "%d.%m.%Y"
                    )
                    for x in range(1, d, 1)
                ]
            except ValueError:
                d -= 1
                continue
            return self.days

    def getMonthInCharakters(self):
        return datetime.strftime(self.date_time_now, "%B")

    def getDateString(self):
        return datetime.strftime(self.date_time_now, "%d.%m.%y")

    def getTimeString(self):
        return datetime.strftime(self.date_time_now, "%H:%M")