2021-06-14 12:40:12 +01:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
import pytz
|
|
|
|
|
from dateutil import parser
|
2022-11-29 10:58:59 -05:00
|
|
|
|
2021-06-14 12:40:12 +01:00
|
|
|
|
|
|
|
|
def get_current_financial_year():
|
2023-06-12 17:00:20 -04:00
|
|
|
now = datetime.now(pytz.utc)
|
2021-06-14 12:40:12 +01:00
|
|
|
current_month = int(now.strftime('%-m'))
|
|
|
|
|
current_year = int(now.strftime('%Y'))
|
2022-12-01 10:18:12 -05:00
|
|
|
return current_year if current_month > 9 else current_year - 1
|
2021-06-14 12:40:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2022-11-28 20:39:24 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_naive_dt(dt):
|
|
|
|
|
return parser.parse(dt, ignoretz=True)
|