From 2ef42b865cd88f274958bde780c2731e0434eb34 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 19 Apr 2014 00:27:29 +0200 Subject: Add support for automatic local-time-offset --- src/ParserConfigfile.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/ParserConfigfile.cpp') diff --git a/src/ParserConfigfile.cpp b/src/ParserConfigfile.cpp index b477f1d..f515a5c 100644 --- a/src/ParserConfigfile.cpp +++ b/src/ParserConfigfile.cpp @@ -191,18 +191,26 @@ void parse_configfile(string configuration_file, ensemble->international_table = pt_ensemble.get("international-table", 0); - double lto_hours = pt_ensemble.get("local-time-offset", 0.0); - if (round(lto_hours * 2) != lto_hours * 2) { - etiLog.level(error) << "Ensemble local time offset " << - lto_hours << "h cannot be expressed in half-hour blocks."; - throw runtime_error("ensemble local-time-offset definition error"); - } - if (lto_hours > 12 || lto_hours < -12) { - etiLog.level(error) << "Ensemble local time offset " << - lto_hours << "h out of bounds [-12, +12]."; - throw runtime_error("ensemble local-time-offset definition error"); - } - ensemble->lto = abs(rint(lto_hours * 2)); + string lto_auto = pt_ensemble.get("local-time-offset", ""); + if (lto_auto == "auto") { + ensemble->lto_auto = true; + ensemble->lto = 0; + } + else { + double lto_hours = pt_ensemble.get("local-time-offset", 0.0); + if (round(lto_hours * 2) != lto_hours * 2) { + etiLog.level(error) << "Ensemble local time offset " << + lto_hours << "h cannot be expressed in half-hour blocks."; + throw runtime_error("ensemble local-time-offset definition error"); + } + if (lto_hours > 12 || lto_hours < -12) { + etiLog.level(error) << "Ensemble local time offset " << + lto_hours << "h out of bounds [-12, +12]."; + throw runtime_error("ensemble local-time-offset definition error"); + } + ensemble->lto_auto = false; + ensemble->lto = abs(rint(lto_hours * 2)); + } int success = -5; string ensemble_label = pt_ensemble.get("label"); -- cgit v1.2.3