TZ aware
This commit is contained in:
parent
40cb9bb845
commit
cfcf23a84d
2 changed files with 6 additions and 3 deletions
|
@ -3,6 +3,7 @@ import os
|
|||
import calendar
|
||||
import datetime
|
||||
|
||||
import pytz
|
||||
import requests
|
||||
import dateutil.parser
|
||||
|
||||
|
@ -12,9 +13,10 @@ host = os.environ.get('FIREFLY_API_HOST')
|
|||
|
||||
|
||||
def _get_budgets():
|
||||
budgets_json = requests.get(
|
||||
budgets_req = requests.get(
|
||||
host + "/api/v1/budgets", headers=header
|
||||
).json()
|
||||
)
|
||||
budgets_json = budgets_req.json()
|
||||
budgets = budgets_json.get('data')
|
||||
while "next" in budgets_json.get('links'):
|
||||
budgets_json = requests.get(
|
||||
|
@ -35,7 +37,7 @@ def _get_current_limit(budget_id):
|
|||
).json()
|
||||
budgets.extend(budget_json.get('data'))
|
||||
|
||||
today = datetime.datetime.combine(datetime.date.today(), datetime.datetime.min.time())
|
||||
today = datetime.datetime.combine(datetime.date.today(), datetime.datetime.min.time()).replace(tzinfo=pytz.UTC)
|
||||
return [
|
||||
budget for budget in budgets
|
||||
if today >= dateutil.parser.parse(budget.get('attributes').get('start')) and today <= dateutil.parser.parse(budget.get('attributes').get('end'))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Flask==1.1.2
|
||||
python-dateutil==2.8.1
|
||||
requests==2.24.0
|
||||
pytz==2021.1
|
||||
|
|
Loading…
Reference in a new issue