From ccdebbb822ee49f89f3b2e5c0de0510258cddbc5 Mon Sep 17 00:00:00 2001 From: Elena Mamontova Date: Thu, 17 Nov 2016 10:13:13 +0200 Subject: [PATCH] Ticket. ConvChangePolicyTimeout() function definition added. The function readTime() replaced by ConvChangePolicyTimeout() for the changePolicyTimeout in SGCONF::MaybeSet in AddTariffFunction(), ChgTariffFunction. --- projects/sgconf/tariffs.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/sgconf/tariffs.cpp b/projects/sgconf/tariffs.cpp index c0d30a12..6ab4e871 100644 --- a/projects/sgconf/tariffs.cpp +++ b/projects/sgconf/tariffs.cpp @@ -94,6 +94,14 @@ else throw SGCONF::ACTION::ERROR("Change policy should be 'allow', 'to_cheap', 'to_expensive' or 'deny'. Got: '" + value + "'"); } +void ConvChangePolicyTimeout(const std::string & value, RESETABLE & res) +{ +struct tm brokenTime; +if (stg_strptime(value.c_str(), "%Y-%m-%d %H:%M:%S", &brokenTime) == NULL) + throw SGCONF::ACTION::ERROR("Credit expiration should be in format 'YYYY-MM-DD HH:MM:SS'. Got: '" + value + "'"); +res = stg_timegm(&brokenTime); +} + void ConvTraffType(const std::string & value, RESETABLE & res) { std::string lowered = ToLower(value); @@ -369,7 +377,7 @@ SGCONF::MaybeSet(options, "passive-cost", conf.tariffConf.passiveCost); SGCONF::MaybeSet(options, "traff-type", conf.tariffConf.traffType, ConvTraffType); SGCONF::MaybeSet(options, "period", conf.tariffConf.period, ConvPeriod); SGCONF::MaybeSet(options, "change-policy", conf.tariffConf.changePolicy, ConvChangePolicy); -SGCONF::MaybeSet(options, "change-policy-timeout", conf.tariffConf.changePolicyTimeout, readTime(conf.tariffConf.changePolicyTimeout)); +SGCONF::MaybeSet(options, "change-policy-timeout", conf.tariffConf.changePolicyTimeout, ConvChangePolicyTimeout); SGCONF::MaybeSet(options, "times", conf.dirPrice, ConvTimes); SGCONF::MaybeSet(options, "day-prices", conf.dirPrice, ConvDayPrices); SGCONF::MaybeSet(options, "night-prices", conf.dirPrice, ConvNightPrices); @@ -404,7 +412,7 @@ SGCONF::MaybeSet(options, "passive-cost", conf.tariffConf.passiveCost); SGCONF::MaybeSet(options, "traff-type", conf.tariffConf.traffType, ConvTraffType); SGCONF::MaybeSet(options, "period", conf.tariffConf.period, ConvPeriod); SGCONF::MaybeSet(options, "change-policy", conf.tariffConf.changePolicy, ConvChangePolicy); -SGCONF::MaybeSet(options, "change-policy-timeout", conf.tariffConf.changePolicyTimeout, readTime(conf.tariffConf.changePolicyTimeout)); +SGCONF::MaybeSet(options, "change-policy-timeout", conf.tariffConf.changePolicyTimeout, ConvChangePolicyTimeout); SGCONF::MaybeSet(options, "times", conf.dirPrice, ConvTimes); SGCONF::MaybeSet(options, "day-prices", conf.dirPrice, ConvDayPrices); SGCONF::MaybeSet(options, "night-prices", conf.dirPrice, ConvNightPrices); -- 2.44.2