Skip to content
Snippets Groups Projects
Commit 9d847fb6 authored by Lene Wasskog's avatar Lene Wasskog
Browse files

feat: Local TZ as env var, use it for checking today. Update docs.

parent d6e567a3
Branches
No related tags found
No related merge requests found
......@@ -33,7 +33,8 @@ load_dotenv()
config = configparser.ConfigParser()
config.read("PSILARTEMP.cfg")
today = datetime.now().date()
local_timezone = pytz.timezone(os.getenv("LOCAL_TIMEZONE"))
today = datetime.now(local_timezone).date()
if len(sys.argv) > 1:
year = int(sys.argv[1])
else:
......@@ -46,9 +47,6 @@ home_dir = os.getenv("HOME_DIR")
out_path = f'{os.getenv("DATA_DIR")}{year}/'
os.makedirs(out_path, exist_ok=True)
# TODO: Put timezone out in .env
local_timezone = pytz.timezone("Europe/Oslo")
# Ensure that model is not run for future year
if year > today.year:
print(f"Cannot run model for future year ({year}). Quit.")
......@@ -56,7 +54,7 @@ if year > today.year:
# If we are before the recurring start date, exit nicely
start_time = datetime.strptime(f"{year}-{recurring_start_date}","%Y-%m-%d")
if datetime.now() <= start_time:
if today <= start_time:
print(f"Today is before the configured start time of {start_time}. Exiting.")
exit(0)
......
......@@ -43,6 +43,10 @@ The model (as per 2023-11-14) assumes that a weather data file named `met_1_0km_
It is required that you have set the following environment variables:
```bash
# Recurring start date (MM-DD)
RECURRING_START_DATE=04-01
# Local time zone
LOCAL_TIMEZONE=Europe/Oslo
# Where your application resides
HOME_DIR=/home/foo/PSILARTEMP/
# Path to the weather data
......
......@@ -2,6 +2,8 @@
# Recurring start date (MM-DD)
RECURRING_START_DATE=04-01
# Local time zone
LOCAL_TIMEZONE=Europe/Oslo
# Where your application resides
HOME_DIR=/home/foo/PSILARTEMP/
# Path to the weather data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment