mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-18 21:44:11 -04:00
put timezone dt in config
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import os
|
||||
import pytz
|
||||
|
||||
from app.cloudfoundry_config import cloud_config
|
||||
|
||||
@@ -13,6 +14,7 @@ class Config(object):
|
||||
LOGO_CDN_DOMAIN = 'static-logos.notifications.service.gov.uk' # TODO use our own CDN
|
||||
ASSETS_DEBUG = False
|
||||
TIMEZONE = os.environ.get('TIMEZONE', 'America/New_York')
|
||||
PY_TIMEZONE = pytz.timezone(TIMEZONE)
|
||||
|
||||
# Credentials
|
||||
ADMIN_CLIENT_SECRET = os.environ.get('ADMIN_CLIENT_SECRET')
|
||||
|
||||
@@ -77,8 +77,8 @@ def get_time_value_and_label(future_time):
|
||||
return (
|
||||
future_time.replace(tzinfo=None).isoformat(),
|
||||
'{} at {} ET'.format(
|
||||
get_human_day(future_time.astimezone(pytz.timezone(current_app.config['TIMEZONE']))),
|
||||
get_human_time(future_time.astimezone(pytz.timezone(current_app.config['TIMEZONE'])))
|
||||
get_human_day(future_time.astimezone(current_app.config['PY_TIMEZONE'])),
|
||||
get_human_time(future_time.astimezone(current_app.config['PY_TIMEZONE']))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ from app.main import main
|
||||
@main.route("/performance")
|
||||
def performance():
|
||||
stats = performance_dashboard_api_client.get_performance_dashboard_stats(
|
||||
start_date=(datetime.now(pytz.timezone(current_app.config['TIMEZONE'])) - timedelta(days=7)).date(),
|
||||
end_date=datetime.now(pytz.timezone(current_app.config['TIMEZONE'])).date(),
|
||||
start_date=(datetime.now(current_app.config['PY_TIMEZONE']) - timedelta(days=7)).date(),
|
||||
end_date=datetime.now(current_app.config['PY_TIMEZONE']).date(),
|
||||
)
|
||||
stats['organisations_using_notify'] = sorted(
|
||||
[
|
||||
|
||||
@@ -4,11 +4,11 @@ import pytz
|
||||
from dateutil import parser
|
||||
from notifications_utils.timezones import convert_utc_to_local_timezone
|
||||
|
||||
from flask import current_app
|
||||
|
||||
|
||||
def get_current_financial_year():
|
||||
now = convert_utc_to_local_timezone(
|
||||
datetime.utcnow()
|
||||
)
|
||||
now = datetime.now(current_app.config['PY_TIMEZONE'])
|
||||
current_month = int(now.strftime('%-m'))
|
||||
current_year = int(now.strftime('%Y'))
|
||||
return current_year if current_month > 3 else current_year - 1
|
||||
|
||||
Reference in New Issue
Block a user