1
0
Fork 0
forked from Fuji/Fuji

Add function to get current month's start and end dates

This commit is contained in:
Maarceeli 2025-04-16 10:03:54 +02:00
parent f1ed6dcab4
commit 0441e00a9e

View file

@ -1,6 +1,7 @@
import keyring import keyring
import os import os
from pathlib import Path from pathlib import Path
from datetime import datetime, timedelta
import configparser import configparser
import subprocess import subprocess
import sys import sys
@ -90,3 +91,15 @@ def restart(page: ft.Page):
page.window.destroy() page.window.destroy()
except FileNotFoundError: except FileNotFoundError:
exit() exit()
def get_current_month_dates():
today = datetime.today()
start_date = today.replace(day=1)
# To get the last day, move to the next month, then subtract one day
if today.month == 12:
next_month = today.replace(year=today.year + 1, month=1, day=1)
else:
next_month = today.replace(month=today.month + 1, day=1)
end_date = next_month - timedelta(days=1)
return start_date.strftime("%Y-%m-%d"), end_date.strftime("%Y-%m-%d")