|
|
@ -45,21 +45,27 @@ template<class D> std::pair<TIndex, MString> GetTIndexes(const D& data, const CL |
|
|
|
MString regex = args.at("time"); |
|
|
|
MString regex = args.at("time"); |
|
|
|
MDateTime time; |
|
|
|
MDateTime time; |
|
|
|
|
|
|
|
|
|
|
|
if(time.FromString(regex)) return {TIndex(1, GetTIndex(data, time)), ""}; // Time, not regex
|
|
|
|
if(time.FromString(regex)) // Time, not regex
|
|
|
|
if(regex == "BEGIN" || regex == "BEG" || regex == "FIRST") return {TIndex(1, 0), ""}; // First time
|
|
|
|
tindexes.push_back(GetTIndex(data, time)); |
|
|
|
if(regex == "END" || regex == "LAST") return {TIndex(1, data.NTimes() - 1), ""}; // Last time
|
|
|
|
else if(regex == "BEGIN" || regex == "BEG" || regex == "FIRST") // First time
|
|
|
|
|
|
|
|
tindexes.push_back(0); |
|
|
|
michlib::RegExpSimple reg(regex.Buf()); |
|
|
|
else if(regex == "END" || regex == "LAST") // Last time
|
|
|
|
if(reg.Compile() != 0) return {tindexes, "Bad regular expression: " + regex}; |
|
|
|
tindexes.push_back(data.NTimes() - 1); |
|
|
|
|
|
|
|
else // Regular expression
|
|
|
|
for(size_t i = 0; i < data.NTimes(); i++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
MString date = data.Time(i).ToString(); |
|
|
|
michlib::RegExpSimple reg(regex.Buf()); |
|
|
|
if(reg.Match(date.Buf())) tindexes.push_back(i); |
|
|
|
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() == 0) return {tindexes, "There are no times matching the regular expression: " + regex}; |
|
|
|
if(tindexes.size() == 1) |
|
|
|
if(tindexes.size() == 1) |
|
|
|
pars.SetParameter("time", data.Time(tindexes[0]).ToString()); |
|
|
|
pars.SetParameter("time", data.Time(tindexes[0]).ToTString()); |
|
|
|
else |
|
|
|
else |
|
|
|
pars.SetParameter("timeregex", args.at("time")); |
|
|
|
pars.SetParameter("timeregex", args.at("time")); |
|
|
|
} |
|
|
|
} |
|
|
@ -98,8 +104,8 @@ template<class D> std::pair<TIndex, MString> GetTIndexes(const D& data, const CL |
|
|
|
for(size_t i = 0; i < ie - ib + 1; i++) tindexes[i] = i + ib; |
|
|
|
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()}; |
|
|
|
if(tindexes.size() == 0) return {tindexes, "There are no times between " + b.ToString() + " and " + e.ToString()}; |
|
|
|
pars.SetParameter("timeb", b.ToString()); |
|
|
|
pars.SetParameter("timeb", b.ToTString()); |
|
|
|
pars.SetParameter("timee", e.ToString()); |
|
|
|
pars.SetParameter("timee", e.ToTString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return {tindexes, ""}; |
|
|
|
return {tindexes, ""}; |
|
|
|