X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/2ecac495e165f5247a5e33669588a4ca8c2e8266..d8845c7819caac09b95c4cdf1e8d48cc1cb1b7a6:/projects/sgconf/tariffs.cpp diff --git a/projects/sgconf/tariffs.cpp b/projects/sgconf/tariffs.cpp index 87d07d1a..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,6 +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, ConvChangePolicyTimeout); SGCONF::MaybeSet(options, "times", conf.dirPrice, ConvTimes); SGCONF::MaybeSet(options, "day-prices", conf.dirPrice, ConvDayPrices); SGCONF::MaybeSet(options, "night-prices", conf.dirPrice, ConvNightPrices); @@ -403,6 +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, ConvChangePolicyTimeout); SGCONF::MaybeSet(options, "times", conf.dirPrice, ConvTimes); SGCONF::MaybeSet(options, "day-prices", conf.dirPrice, ConvDayPrices); SGCONF::MaybeSet(options, "night-prices", conf.dirPrice, ConvNightPrices);