123456789101112131415161718192021222324252627 |
- import calendar
- import datetime
- import typer
- filename = "test.csv"
- archive_folder = "Archiv"
- def main():
- today = datetime.datetime.now().date()
- end_of_month = last_day_of_month(today)
- last_month = today - datetime.timedelta(days=30)
- end_of_last_month = last_day_of_month(last_month)
- if today == end_of_month:
- archive_filename = archive_folder + "\\" + filename[:-4] + "_" + today.isoformat() + filename[-4:]
- def last_day_of_month(any_date: datetime.date) -> datetime.date:
- end_of_month = calendar.monthrange(any_date.year, any_date.month)[2]
- return datetime.date(any_date.year, any_date.month, end_of_month)
- if __name__ == "__main__":
- typer.run(main)
|