Add function to get current month's start and end dates
This commit is contained in:
parent
f1ed6dcab4
commit
0441e00a9e
1 changed files with 14 additions and 1 deletions
15
src/utils.py
15
src/utils.py
|
@ -1,6 +1,7 @@
|
|||
import keyring
|
||||
import os
|
||||
from pathlib import Path
|
||||
from datetime import datetime, timedelta
|
||||
import configparser
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -89,4 +90,16 @@ def restart(page: ft.Page):
|
|||
subprocess.Popen([python] + sys.argv)
|
||||
page.window.destroy()
|
||||
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")
|
Loading…
Add table
Reference in a new issue