mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 11:23:48 -05:00
This changeset removes the PY_TIMEZONE configuration variable and updates all references to it to refer directly to pytz.utc instead. It also cleans up a few of the import statements and removes those that are no longer needed (like the current_app reference from Flask). Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
22 lines
540 B
Python
22 lines
540 B
Python
from datetime import datetime
|
|
|
|
import pytz
|
|
from dateutil import parser
|
|
|
|
|
|
def get_current_financial_year():
|
|
now = datetime.now(pytz.utc)
|
|
current_month = int(now.strftime('%-m'))
|
|
current_year = int(now.strftime('%Y'))
|
|
return current_year if current_month > 9 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
|
|
|
|
|
|
def parse_naive_dt(dt):
|
|
return parser.parse(dt, ignoretz=True)
|