The unified diff between revisions [b3f30c54..] and [13704fef..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'src/parsing.cpp'
#
#
# patch "src/parsing.cpp"
# from [df0419ff36e21c79ca86fb06d7aadbde8c92b733]
# to [07004ffd721f7f70ccb2f50f0a1f4a7e98c028cb]
#
============================================================
--- src/parsing.cpp df0419ff36e21c79ca86fb06d7aadbde8c92b733
+++ src/parsing.cpp 07004ffd721f7f70ccb2f50f0a1f4a7e98c028cb
@@ -55,6 +55,37 @@ std::string to_string(u64bit n, u32bit m
}
/*************************************************
+* Convert a string into a time duration *
+*************************************************/
+u32bit timespec_to_u32bit(const std::string& timespec)
+ {
+ if(timespec == "")
+ return 0;
+
+ const char suffix = timespec[timespec.size()-1];
+ std::string value = timespec.substr(0, timespec.size()-1);
+
+ u32bit scale = 1;
+
+ if(Charset::is_digit(suffix))
+ value += suffix;
+ else if(suffix == 's')
+ scale = 1;
+ else if(suffix == 'm')
+ scale = 60;
+ else if(suffix == 'h')
+ scale = 60 * 60;
+ else if(suffix == 'd')
+ scale = 24 * 60 * 60;
+ else if(suffix == 'y')
+ scale = 365 * 24 * 60 * 60;
+ else
+ throw Decoding_Error("timespec_to_u32bit: Bad input " + timespec);
+
+ return scale * to_u32bit(value);
+ }
+
+/*************************************************
* Parse a SCAN-style algorithm name *
*************************************************/
std::vector<std::string> parse_algorithm_name(const std::string& namex)