From 17002e2d9f32695b07475411edc445b8266e3887 Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Fri, 15 Dec 2023 15:03:57 +1000 Subject: [PATCH] Time was not written to the output file --- include/actiondep.h | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/include/actiondep.h b/include/actiondep.h index 2cc8367..08f7f35 100644 --- a/include/actiondep.h +++ b/include/actiondep.h @@ -45,21 +45,27 @@ template std::pair GetTIndexes(const D& data, const CL MString regex = args.at("time"); MDateTime time; - if(time.FromString(regex)) return {TIndex(1, GetTIndex(data, time)), ""}; // Time, not regex - if(regex == "BEGIN" || regex == "BEG" || regex == "FIRST") return {TIndex(1, 0), ""}; // First time - if(regex == "END" || regex == "LAST") return {TIndex(1, data.NTimes() - 1), ""}; // Last time - - michlib::RegExpSimple reg(regex.Buf()); - if(reg.Compile() != 0) return {tindexes, "Bad regular expression: " + regex}; - - for(size_t i = 0; i < data.NTimes(); i++) + if(time.FromString(regex)) // Time, not regex + tindexes.push_back(GetTIndex(data, time)); + else if(regex == "BEGIN" || regex == "BEG" || regex == "FIRST") // First time + tindexes.push_back(0); + else if(regex == "END" || regex == "LAST") // Last time + tindexes.push_back(data.NTimes() - 1); + else // Regular expression { - MString date = data.Time(i).ToString(); - if(reg.Match(date.Buf())) tindexes.push_back(i); + michlib::RegExpSimple reg(regex.Buf()); + if(reg.Compile() != 0) return {tindexes, "Bad regular expression: " + regex}; + + for(size_t i = 0; i < data.NTimes(); i++) + { + MString date = data.Time(i).ToString(); + if(reg.Match(date.Buf())) tindexes.push_back(i); + } } + if(tindexes.size() == 0) return {tindexes, "There are no times matching the regular expression: " + regex}; if(tindexes.size() == 1) - pars.SetParameter("time", data.Time(tindexes[0]).ToString()); + pars.SetParameter("time", data.Time(tindexes[0]).ToTString()); else pars.SetParameter("timeregex", args.at("time")); } @@ -98,8 +104,8 @@ template std::pair GetTIndexes(const D& data, const CL for(size_t i = 0; i < ie - ib + 1; i++) tindexes[i] = i + ib; if(tindexes.size() == 0) return {tindexes, "There are no times between " + b.ToString() + " and " + e.ToString()}; - pars.SetParameter("timeb", b.ToString()); - pars.SetParameter("timee", e.ToString()); + pars.SetParameter("timeb", b.ToTString()); + pars.SetParameter("timee", e.ToTString()); } return {tindexes, ""};