2021-06-14 12:40:12 +01:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
import pytz
|
|
|
|
|
from dateutil import parser
|
2022-11-22 12:00:29 -05:00
|
|
|
from notifications_utils.timezones import convert_utc_to_local_timezone
|
2021-06-14 12:40:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_current_financial_year():
|
2022-11-22 12:00:29 -05:00
|
|
|
now = convert_utc_to_local_timezone(
|
2021-06-14 12:40:12 +01:00
|
|
|
datetime.utcnow()
|
|
|
|
|
)
|
|
|
|
|
current_month = int(now.strftime('%-m'))
|
|
|
|
|
current_year = int(now.strftime('%Y'))
|
|
|
|
|
return current_year if current_month > 3 else current_year - 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_less_than_days_ago(date_from_db, number_of_days):
|
|
|
|
|
return (
|
|
|
|
|
datetime.utcnow().astimezone(pytz.utc) - parser.parse(date_from_db)
|
|
|
|
|
).days < number_of_days
|